Forum Moderators: phranque
I have decided to Redirect 301 of a site.
Most of the URLs in this site have a double colon ":". Google indexed these URLs inconsistently. Sometimes it converted ":" to "%3A" and others it kept the same. This is not a problem but the real problem is when these URLs were 301-redirected. All "%3A" became "%253A". Note that a character 25 was added. This means the new URLs has been redirected to wrong addresses.
My questions will be:
1. How to 301 redirect without "%" alternated?
2. How to change "%253A" back to the initial ":" by htaccess rewrite?
Thanks,
FromRocky
If your "::" sequence is appearing in part of the URL where it is not allowed, then User-agents such as browsers and robots are required to escape those characters, and that is why the %25 character is added.
This problem can be fixed, but it's a bit tricky.
Jim
Index:
www.siteold.com/?q=widgets&sa=search&cof=FORID%3A1&...
301 redirect
www.sitenew.com/?q=widgets&sa=search&cof=FORID%253A1&...
How to?
www.sitenew.com/?q=widgets&sa=search&cof=FORID:1&...
or at least to
www.sitenew.com/?q=widgets&sa=search&cof=FORID%3A1&...
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /\?(([^&]+&)*)cof=FORID\%(25)*3A([0-9]+)(&[^\ ]+)?\ HTTP/
RewriteRule ^$ http://www.new-example.com/?%1cof=FORID:%4%5 [NE,R=301,L]
To clarify, THE_REQUEST is the original client HTTP request header, exactly as received from the browser or robot. For example:
GET /?q=widgets&sa=search&cof=FORID%25253A1&foo=bar HTTP/1.1
GET /robots.txt HTTP/1.1
To keep this post simple, I have assumed that you have set up and enabled mod_rewrite in your /.htaccess file, and that you already have other working RewriteRules.
Jim
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /[^/]+/\?(([^&]+&)*)cof=FORID\%(25)*3A([0-9]+)(&[^\ ]+)?\ HTTP/
RewriteRule ^$ [new-example.com...] [NE,R=301,L]
It works very well.
However, I'm unable to rewrite it for a page
www.www.new-example.com/page.php?q=widgets&sa=search&cof=FORID%3A1&...
& 301 redirect to
www.www.new-example.com/page.php?q=widgets&sa=search&cof=FORID:1&...
FromRocky