开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜