Forum Moderators: phranque

Message Too Old, No Replies

Dynamic URL redirects passing variables

Dynamic redirects still passing variables, even with question mark at end.

         

SEOHolicc

2:39 pm on Aug 12, 2009 (gmt 0)

10+ Year Member



Hey everyone :),

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?

jdMorgan

11:27 pm on Aug 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd look for other rules in this file or in other .htaccess files in the /news/newsroom/ path that may be interfering. Make sure that all redirects are done before any internal rewrites.

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

g1smd

12:09 am on Aug 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Your first RewriteRule is incorrect.

RewriteRule cannot 'see' query strings. You need to add a RewriteCond for that.

jdMorgan

12:34 am on Aug 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



... as in the second rule that SEOHolicc tried.

It's very odd that the rules that *were* invoked passed the query value, but not the name. This is one reason I'm suspecting a scripting error (or a very 'sick' server).

Jim

SEOHolicc

1:50 pm on Aug 13, 2009 (gmt 0)

10+ Year Member



jdMorgan, you were right. It was another rule in the .htaccess.

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 :)

g1smd

9:40 pm on Aug 13, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you also have a non-www to www fixup rule somewhere in there?

Test your server with both www and non-www requests and make sure they properly redirect, and that the redirect is one hop, not a chain.

SEOHolicc

2:26 pm on Aug 17, 2009 (gmt 0)

10+ Year Member



You mean to check by using http header check plugin right to make sure it goes directly back to the www version instead of passing through other pages?

I checked it and that seems to be working fine.