Well, I screwed up a bit during my re-write of a vbulletin thread (many thanks to J.D btw). Google indexed (and cached) my page as: http://www.clantt.com/carinsurance/?t=6740 Now, normally, this wouldn't be too bad since my ranking is high and my vistors can see the content. However, the adsense ads are all screwy at this specific url. When it's re-written to the URL below, the adsense ads come up as they should and everything is fine. I need to mod-rewrite that to: http://www.clantt.com/carinsurance/ I've tried: RewriteEngine On RewriteRule ^carinsurance/\?t=6740$ /carinsurance/ [R=301, L] - gives a 500 Internal server error. On the htaccess file in my root. I've also tried modifications of that in the car insurance directory such as: RewriteEngine On RewriteRule ^\?t=6740$ [R=301, L] Which also didn't work. I've also tried RewriteEngine On RewriteRule ^carinsurance/?t=6740$ /carinsurance/ [R=301, L] Still gives a 500. I've also tried: redirect 301 /carinsurance/?t=6740 http://www.clantt.com/carinsurance/ And still no go. Edit: Edited the redirect 301 line to put what I did try (typed this a bit rushed just before I headed off to work).
Thanks for the reply. I actually did try that. My last 301 redirect line was typed wrong (was a bit rushed when I made this post just before I headed off to work). I've edited the original post. I've read somewhere that different versions treat the ? operator differently when trying to redirect it. Placing a \ before that character should take care of the redirect, at least I presume that's the way it should work.
Sounds like you're thanking me for helping you to screw up a bit RewriteRule ^\?t=6740$ [R=301, L] Won't work; will look for this URL: ?t=6740 Redirect isn't for this case. Use redirect when you need to match the beginning of the URL path and change the matched part to another path. As far as your question goes, as an quick test, try changing it to RewriteRule ^carinsurance/\?t=6740$ /carinsurance_/ [R=301,L] Test it and change it quickly back before anybody picks up this URL. Let me know if it worked this way. J.D.
Haha, no JD, didn't mean to thank you for messing me up. I messed myself up learning the intricatcies of Mod Rewriting. But, that's how we learn this stuff I guess, trial and error. I'll give your suggestion a shot. -Richard
It was not supposed to fix the problem. It was a test. Did you still get 500 or you got a "not found" error? J.D.
Didn't get anything. http://www.clantt.com/carinsurance/?t=6740 Is the url I'm still getting. No 500 error or not found.
Are you saying that RewriteRule ^carinsurance/\?t=6740$ /carinsurance_/ [R=301,L] with the underscore is in .htaccess in the root directory right now? Do you get 500 when you remove the underscore? J.D.
I'm not getting a 500 with or without the _ right now (I was this morning, now I'm not...strange). Currently it's in the .htaccess as follows: RewriteRule ^carinsurance/\?t=6740$ /carinsurance/ [R=301,L]
Could it be that you have /carinsurance/ rule somewhere else and it gets executed before this one? Also, try this: RewriteRule ^carinsurance/.*\?t=6740$ /carinsurance/ [R=301,L] J.D.
I completely forgot that query strings are not supposed to be used in rewrite rules. Here's the working version: RewriteCond %{QUERY_STRING} ^t=6740$ RewriteRule ^carinsurance/$ /carinsurance/? [R=301,L] Code (markup): The question mark at the end of the substitution removes all query string arguments (it will not appear in the resulting URL). If omitted, the text after the ? in the original URL will be appended to the substitution. J.D.