Forum Moderators: phranque

Message Too Old, No Replies

redirect to a subdirectory

can't get it to work

         

nancyb

8:11 am on Nov 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



google currently has a listing for several of my new pages but somehow a space got added before the subdirectory name:

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 :)

jdMorgan

3:08 pm on Nov 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



nancyb,

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

If that does not cause server errors, but does not accomplish the job, you might try looking for an encoded space instead:

RedirectMatch 301 ^/directory/\%20sub/file\.htm$ http://www.domain.com/directory/sub/file.htm

Jim

nancyb

10:43 pm on Nov 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thank you, Jim! The second one with the encoded space worked.

I had tried using the encoded space and RedirectMatch, but didn't add the $ after htm or the \ before .htm.

WebmasterWorld (and me especially) are so lucky you take the time to help us learn and fix our mistakes! :)

jdMorgan

10:55 pm on Nov 16, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



nancyb,

There are many others here who give their time as well...

Glad you got it working!

Jim

nancyb

12:19 am on Nov 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I apologize. I didn't mean to exclude all the others that help, just wanted to let you know how much your help has meant and to thank you again for taking on this forum as mod.

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 :)