Reputation: 13
ok, first post on stackoverflow, here i go.
i'm strugling to write a 301 redirect for a migration of an old site. The site uses dynamic url's and these don't seem to work.
old site: http://oldsite.com/index.php?actie=contact
new site: http://newsite.com/contact
Options +FollowSymlinks
RewriteEngine on
Redirect 301 /index.php?actie=contact http://newsite.com/contact
Upvotes: 1
Views: 34
Reputation: 143866
You can't match against the query string in a Redirect
, you have to use mod_rewrite and the %{QUERY_STRING}
variable. (also note that Redirect
is a mod_alias directive, and has nothing to do with the rewrite engine)
Options +FollowSymlinks
RewriteCond %{QUERY_STRING} ^actie=contact(^|&)
RewriteRule ^index\.php http://newsite.com/contact? [L,R=301]
If you want to make it a general rule to match anything after the actie=
, then:
RewriteCond %{QUERY_STRING} ^actie=([^&]+)
RewriteRule ^index\.php http://newsite.com/%1? [L,R=301]
Upvotes: 0
Reputation: 784958
Redirec
directive cannot match query string.
Use your rule like this in root .htaccess:
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{QUERY_STRING} ^actie=contact$ [NC]
RewriteRule ^index\.php$ http://newsite.com/contact? [L,NC,R=301]
Upvotes: 1