Forum Moderators: phranque

Message Too Old, No Replies

Redirecting URLs with %'s In Them

Another mod_rewrite issue

         

ambition

7:26 pm on Jan 11, 2007 (gmt 0)

10+ Year Member



Hello,

I am working on redirecting a specific url which is indexed in google, I assume because someone made an improper link. The url shows up in the index like this:

www.example.com/dir/1/10.php%22%20TARGET=%22_blank%22%3EAnchor%20Text%20Here%3C/A%3E

Of course I want that to redirect to www.example.com/dir/1/10.php.

I have been trying various things but I cannot seem to get the url to match any RewriteCond statement:

RewriteCond %{REQUEST_URI} ^TARGET
RewriteRule ^(.*)$ http://www.example.com/dir/1/10.php [R=301,L]

Any ideas on this one?

[edited by: jdMorgan at 7:46 pm (utc) on Jan. 11, 2007]
[edit reason] example.com [/edit]

jdMorgan

7:44 pm on Jan 11, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your start anchor "^" is the main problem, and you can make this more efficient by specifying the base page of the corrupted URL in the RewriteRule pattern, and moving the "TARGET" there as well:

RewriteRule ^dir/1/10\.php.*TARGET http://www.example.com/dir/1/10.php [R=301,L]

Jim

[edited by: jdMorgan at 7:45 pm (utc) on Jan. 11, 2007]

ambition

8:25 pm on Jan 11, 2007 (gmt 0)

10+ Year Member



Wow. So in this case I don't even need the RewriteCond? Thanks again for the fast reply.