Forum Moderators: phranque
I'm having a redirect issue. I think I have these redirects set up properly in the .htaccess file, but for some reason they are passing the variables onto the new URL.
These are the various rewrites I've tried with no luck:
RewriteRule ^news/newsroom.php?date=April+2005$ http://www.example.com/table/news-releases/news/? [R=301,L]
RewriteCond %{QUERY_STRING} &?date=April+2005
RewriteRule ^$ http://www.example.com/table/news-releases/news/? [R=301,L]
RewriteCond %{QUERY_STRING} ^date=April+2005$
RewriteRule ^news/newsroom\.php$ http://www.example.com/table/news-releases/news/? [R=301,L]
They redirect to the appropriate URL but then add the variables to the end, like this;
http://www.example.com/table/news-releases/news/?April+2005
Is there something I'm doing wrong here?
Make sure that that question mark is encoded in 8-bit U.S. ASCII and not UTF-16 or other. In other words, be sure you're using a plain-text editor to write that line, and not some fancy word processor program.
Also, use an HTTP headers checker (e.g. the Live HTTP Headers add-on for Firefox) to verify that it is this initial redirect rule that's going wrong. It might be that case that the redirect is actually working properly, but that when the second (redirected) HTTP request arrives at your server, it's triggering either a separate rule or a script which re-appends a partial query string.
If none of these prove to be the case, then you've likely got a bad Apache installation, and will need to re-install.
Jim
I was also using:
RewriteRule ^newsroom/newsroom.php(.*)$ http://www.example.com/news-events/news-a-events.html$1 [R=301,L]
I added a question mark after "html" of the substitute URL and it works now. I hate it when I miss things like that!
Thanks for your help :)