1

I am working on a website project where we basically move from TYPO3 to a WordPress & Magento-solution.

Before launching the new site, I would like to add rewrite rules to point the old (TYPO3, non-SEF) URLs to the corresponding new ones. I have an Excel-list with around 1000 URLs that I somehow would like to add to htaccess and create 301's. If you have a better approach for this, I'd be thankful.

What I am struggling with is:

The "old" URL structure looks something like ?id=123\&user_e15proddb1_pi1[domain]=42

the correcponding new URL would be /de/alle-produkte/neuheiten.html

RewriteEngine is on, RewriteBase is /.

I tried

RewriteCond %{QUERY_STRING} ^id=123\&user_e15proddb1_pi1[domain]=42$
RewriteRule . /de/alle-produkte/neuheiten.html [R=301,L]

With additionally escaping the _and the [] with no avail. I tried to seperate the {QUERY_STRING}s into two by

RewriteCond %{QUERY_STRING} ^id=123$
RewriteCond %{QUERY_STRING} ^user_e15proddb1_pi1[domain]=42$

followed by TheRule. Also no avail.

Rewriting itself works, because I tried

RewriteRule .id=123\&user_e15proddb1_pi1\[domain\]=42$ /de/alle-produkte/neuheiten.html [R=301,L]

But that only works without the question mark in the beginning.

Could you give me a hint on what I am doing wrong?

2 Answers 2

1

You can use this rule by escaping [ and ]:

RewriteCond %{QUERY_STRING} ^id=123&user_e15proddb1_pi1\[domain\]=42$
RewriteRule ^ /de/alle-produkte/neuheiten.html? [R=302,L]

Also note ? at the end of target URI to strip off any existing query string to prevent a redirect loop.

Sign up to request clarification or add additional context in comments.

2 Comments

I think the dot (.) as selector for the URL to rewrite was somehow wrong. You solution works fine, thanks a lot!
Yes dot in pattern will not match landing page as that would by matched using ^$. It is safer to use ^ to match all the cases.
0

I got a solution to and made this one work:

RewriteCond %{QUERY_STRING} ^id=123\&user\_e15proddb1\_pi1\[domain\]=42$
RewriteRule (.*) /de/alle-produkte/neuheiten.html? [R=301,L]

Proably something with escaping those characters was going wrong when I tried over and over again.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.