Welcome to WebmasterWorld Guest from 54.146.221.231

Forum Moderators: bakedjake

Message Too Old, No Replies

Another redirect question

Redirect all requests within a folder

     
3:41 pm on Jan 25, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


Hello,

I'm trying to redirect all requests within a folder to an index page of another folder. Also, one particular file in that folder needs to redirect to a specific page(it's mirror in new dir).

This is what I have in my .htaccess now:

redirectPermanent /folder/specific_page.html ht*p://www.domain.com/new_folder/specific_page.html
redirectPermanent /folder ht*p://www.domain.com/new_folder

The specific page redirects okay, but other requests within the folder return 404

4:03 pm on Jan 25, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Birdman,

Did you try RedirectMatch?


RedirectPermanent /folder/specific_page.html ht*p://www.domain.com/new_folder/specific_page.html
RedirectMatch /folder/.* ht*p://www.domain.com/new_folder/

(Redirect, RedirectPermanent, and RedirectTemp "keep" anything not matched on the left-side path, and append it to the right-side URL, so the page names in /folder are being appended to your /new_folder URL, which is not what you wanted. RedirectMatch works differently - you must specify a back-reference if you want to "keep" any pathname part.)

Jim

4:13 pm on Jan 25, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


Excellent, jd. Works perfectly! Now I only have to do that for six more folders:)

Thanks for that speedy reply!

[httpd.apache.org...]

4:24 pm on Jan 25, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


Do I need to specify 301 like this?

[R=301]

4:34 pm on Jan 25, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Oops, sorry!

RedirectPermanent /folder/specific_page.html ht*p://www.domain.com/new_folder/specific_page.html
RedirectMatch 301 /folder/.* ht*p://www.domain.com/new_folder/

Jim
4:40 pm on Jan 25, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


Yep, I just used the server header utility [webmasterworld.com] and got 302.

Thanks for the help, jd ;)