简体   繁体   English

将301特定文件夹重定向回根域:如何在.htaccess中进行设置?

[英]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: 亲爱的人们,如何在共享主机上的.Htaccess中设置适当的APACHE规则,以使此条件和规则正常运行:

RewriteCond ...
RewriteRule ...

Where... 哪里...

Condition = If the browser url contains any directory equal to (one|two|three) which are forbidden directories, then... 条件=如果浏览器的url包含等于(one|two|three)任何目录,则该目录为禁止目录,则...

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. 规则=不加载任何页面出现,而是:301到相对根/ ...这样,有效载荷的主域名,无论该域的可能。 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?) 所以:再一次:我不想使用硬编码的绝对域名,而只使用相对根(或删除整个相对URL,就像去正确的根一样?)

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. ......应该这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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