开发者

Redirect 301 specific folders back to Root domain: How to setup in .Htaccess?

开发者 https://www.devze.com 2023-02-21 14:00 出处:网络
Dear folks, How to setup a proper APACHE rulein .Htaccess on shared hosting to get this Condition and Rule working:

Dear folks, How to setup a proper APACHE rule in .Htaccess on shared hosting to get this Condition and Rule working:

RewriteCond ...
RewriteRule ...

Where...

Condition = If the browser url contains any directory equal to (one|two|three) which are forbidden directories, then...

Rule = do not load any pages there, instead: 301 to the relative root / ... that way loading effectively the main domain name, whatever that domain may be. So: once again: I don't want to to use hard coded absolute domain name, just relative root (or erase the entire relative url that would be same as going to the 开发者_运维问答root right?)

Thank you very much for your suggestion.


Something along the lines of...

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/one/
RewriteCond %{REQUEST_URI} ^/two/
RewriteCond %{REQUEST_URI} ^/three/
RewriteRule (.*) http://www.yourdomain.com [R=301,L]

...should do it.

0

精彩评论

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