开发者

How to redirect all subdirectories to the domain's root?

开发者 https://www.devze.com 2023-04-11 01:50 出处:网络
I have a domain with multiple domains parked on it. What I need to do is to redirect every traffic from subdirectories to root path.

I have a domain with multiple domains parked on it.

What I need to do is to redirect every traffic from subdirectories to root path.

f开发者_开发百科or example my domain is example.com when the visitor lands on a subdirectory I want him to be redirected to the root. like this:

http://example.com/foo ==> http://example.com

and also consider the part about parked domains.

http://bar.com/foo == > http://bar.com (parked on example.com)


this rewrite rule rewrites all requests from sub-directory to one level-up(root).

RewriteEngine on

RewriteRule  ^([^/]+)\/(.*)$     $2 [L]


I found the answer and it's done like this:

RewriteRule  ^([^/]+)(.*)$     / [R]

Special thanks to Death.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号