简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM