Forum Moderators: phranque
RewriteCond %{REQUEST_URI} ^(.*)%2520(.*)$
RewriteRule^ (.*)%2520(.*)$ http://www.example.com/$1%20$2 [R=301,L]
The true original URLs would have looked something like:
http://www.example.com/directory%20name/page.html
I'd appreciate any help in getting this corrected. Thanks!
Your best bet is to replace the space with a hyphen and redirect directly to that format (i.e. don't redirect to URLs with a space any more).
RewriteRule ^([^\%]+)\%([0-9]+)(.*)$ http://www.example.com/$1-$3 [R=301,L] [edited by: g1smd at 6:03 pm (utc) on Jan. 1, 2009]
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(.*)%(25)*20([^\ ]*)\ HTTP/
RewriteRule . http://www.example.com/%1-%3 [R=301,L]
GET /directory%20name/page.html HTTP/1.1- or -
GET /directory%2520name/page.html HTTP/1.1
Jim
All things considered, I'm on the verge of just renaming the directories properly and letting the rest of the world (namely the search engines) discover the changes on their own.
Do you mean change the names of the folders on the server itself?
Do you mean change the words in the URLs in links on your pages?
In that case, you should be doing both of those things. Neither should have spaces within.
The redirect is purely to show search engines what the new names are, if they continue to request the old names.
[added] %{HTTP_REQUEST} isn't a valid varname. That would probably be %{REQUEST_URI} you were looking for. But you must use %{THE_REQUEST} in the code I posted, and the pattern must be exactly as shown... No doubt about that. [/added]
Jim
[edited by: jdMorgan at 9:34 pm (utc) on Jan. 2, 2009]
RewriteCond %{REQUEST_URI} ^(.*)\ name/(.*)$
RewriteRule ^(.*)\ (.*)$ http://www.example.com/$1-$2 [R=301,L]
RewriteRule ^([^\ ]*)\ (.*)$ http://www.example.com/$1-$2 [R=301,L]
[edited by: jdMorgan at 4:38 pm (utc) on Jan. 4, 2009]