Jump to content

redirect from any subfolder to root


imperium2335

Recommended Posts

Hi,

 

How do I redirect people who directly go to the following:

 

folder-a/folder-b/folder-c/cheese.html

 

to:

 

www.mysite.com ?

 

the names of the folders are different too except for folder-a, I just want it so you are redirected from anywhere within folder-a if you get what i mean?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/179743-redirect-from-any-subfolder-to-root/
Share on other sites

Cheers, I tried this out:

 

RedirectMatch 301 ^/cake-photo-pages/.*$ http://www.cake-photos.com/

 

and it worked like a charm.

 

Anything bad about using this method I should know about?

 

And will this exclude Googlebot from crawling everything in there? I would love to be able to exclude everyone except Googlebot.

 

Thanks.

To be honest I've never used RedirectMatch before, I'd use this:

RewriteRule ^^/cake-photo-pages/.*$ http://www.cake-photos.com/ [R=301,NC]

Although I don't know which one is better.

 

And yes it will also re-direct googlebot. I think you can specify not to re-direct for certain bots or ip addresses, but I haven't looked into it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.