Forum Topic: Trouble with 301’s & and %

Forum: .htaccess Forum : Redirecting • Posted by Garen Arnold • Updated:

I am having trouble with a 301 redirect with a % in it. The url is:

http://example.com/inmotion-rev&shy%3Biew/

I have this in my .htaccess file:

Redirect permanent /inmotion-rev&shy%3Biew/ http://example.com/inmotion-review/

I'm sure its the & and % that are in the url. Wasn't ever a page on my site, but somewhere somehow there is link pointing to me or Google is crawling that url for some reason.

Thanks,
Garen

8 Replies to “Trouble with 301’s & and %”

Jeff Starr
Posted by Jeff Starr

In my experience you should not encourage rogue links, especially when the URL format does not match currently existing.

That said, it should be possible to catch the % with RedirectMatch, for example:

RedirectMatch 301 \\%3 http://example.com/

The first slash escapes the second slash which escapes the percent symbol. So for example, something like this should work:

RedirectMatch 301 shy\\%3Biew / http://example.com/inmotion-review/

Getting back to my comment about ignoring rogue links, I would do a 410 Gone instead:

RedirectMatch 410 /inmotion-rev&shy\\%3Biew/

That will help weed out the ill request and focus bots on legit URL patterns.

I hope this helps.

Posted by Garen Arnold

Thanks Jeff, I will have to put it in correctly. I have a couple more problem urls, but will sort them out in 2-3 days.

Posted by Garen Arnold

Hey Jeff,

I tried both of those. The 301 didn't redirect the site and the 410 just broke the site with an internal 500 error. Any ideas?

Jeff Starr
Posted by Jeff Starr

Sounds like something else is happening, like maybe other rules are interfering..? I don't know, but you may try changing RedirectMatch to just Redirect in the 410 rule, not sure if RedirectMatch works with 410 or not (off the top of my head).

Posted by Garen Arnold

Yeah I tried it with "Redirect permanent" still no luck. I have 6 errors in WMT, they are similar with the % in them.

Jeff Starr
Posted by Jeff Starr

Not sure then, could be some other rules that are interfering, or even a script doing something with traffic. Also could check if mod_rewrite and mod_alias are enabled on the server.

Posted by Garen Arnold

Ok thanks I might have to contact InMotion support and ask them about that. Just these couple urls and I am good. Oddly enough the url is redirecting to a URL that reviews their company LOL.

Jeff Starr
Posted by Jeff Starr

Yeah that's weird.. definitely ask about it, keeping in mind that what you are trying to do with .htaccess is basic redirecting, which should be straightforward on any Apache server. Good luck!