Forum Moderators: phranque
http*//www.domain.com/directory/ sub/filename.htm
I checked my logs and the bot got the correct path, without the space and the cache works, but the direct link blows up in the browser.
I though it would be quicker to just add a permanent redirect in htaccess than trying to get google to make a corrrection, but I can't get the htaccess to work. Tried putting it in both the root and the subdirectory, but both return 501 for all pages.
Am I not escaping the space correctly or is this totally wrong? All other redirects in my htaccess work properly without returning 501s.
This is what I tried:
RedirectPermanent /directory/\ sub/file.htm http*//www.domain.com/directory/sub/file.htm
I tried to find the answer at Apache Mod Rewrite before posting for help, but became totally lost.
TIA for any enlightenment :)
I haven't tested your code, but it's likely that the space in your match string is the problem; Redirect does not use a very smart parser and only looks for prefix matches. Therefore, I don't think it even recognizes the backslash as an escape character to match a literal space character.
Try RedirectMatch, which *does* support regular-expressions pattern-matching, and can recognize an escaped space.
RedirectMatch 301 ^/directory/\ sub/file\.htm$ http://www.domain.com/directory/sub/file.htm
RedirectMatch 301 ^/directory/\%20sub/file\.htm$ http://www.domain.com/directory/sub/file.htm
Thanks to all who have contributed to these type threads, the questioners who expand my knowledge base by asking and all the respondees who answer and enlighten :)