What's wrong with this htaccess redirect?
-
06-07-2019 - |
Question
I recently turned an old Joomla site into a Wordpress site and I want to redirect the old urls to the correct new ones. For starters I tried to redirect them all to the homepage but even that didnt work.
All the old urls look like website.com/?q=node/1 (or sometimes ?q=user/ etc), so I figured this would be enough:
RewriteCond %{QUERY_STRING} ^q=(.*)
RewriteRule . /home/ [R=301]
Why doesn't this work?
Solution
[EDIT - FINAL SOLUTION - see comments]
RewriteCond %{QUERY_STRING} q=
RewriteRule (.*) lexlijst.nl/$1? [L,R=301]
OTHER TIPS
Have you enabled the rewrite engine? You need to enable it in httpd.conf AND in all virtual hosts, since directives are not inherited. Reference: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html#RewriteEngine
RewriteEngine On
RewriteCond %{QUERY_STRING} ^q=(.*)
RewriteRule . /home/ [R=301]
You can debug this sort of thing by adding a RewriteLog line. I suspect your RewriteRule line is the culprit though. It should be something like:
RewriteRule .* /home/ [R=301]