I'm trying to redirect a url like this:
http://originalwebsite.com/event/detail.html?id=13
to
I've tried the following in my .htaccess
file:
redirect 301 /event/detail.html?id=13 /events
but it's not working...
I've also tried this:
RewriteCond %{QUERY_STRING} /event/detail.html?id=13
RewriteRule (.*) /events [R=301,L]
Could anyone advise me on what I'm doing wrong? It's a pretty bog standard redirect...
the GET
parameter is not required to be passed through, I just want to point old page at new page.
Many thanks
After some further investigation I've discovered that you cannot pass variables in the Redirect
so I've alterthed the code to the below:
RewriteCond %{QUERY_STRING} id=13$
RewriteRule (.*) /events? [L,R=301]
This is working however the issue I am having is that this redirect applies to any URL with id=13
appended to it. I need to be more specific as I want to redirect /event/detail.html?id=13 to /events
(.*) is a catch-all pattern, so if you the rule to be applied for a specific uri only,You can match against that uri in RewriteRule
RewriteCond %{QUERY_STRING} id=13$
RewriteRule ^event/detail\.html$ /events? [L,R=301]