Maison  >  Article  >  développement back-end  >  二级目录下htaccess 301 重定向的配置代码

二级目录下htaccess 301 重定向的配置代码

WBOY
WBOYoriginal
2016-07-25 09:00:331106parcourir
二级目录下的页面,子目录下也存在htaccess文件,配置有自己的规则,根目录的301跳转规则对子目录无效,需要在子目录下重作301重定向。

(301重定向)子目录与根目录的不同之处: 访问地址后面有没有加斜杠所请求的地址会有不同,规则如下:

RewriteBase /news
RewriteCond %{HTTP_HOST} ^jbxue.com [NC]
RewriteRule com(.*)$ http://bbs.it-home.org$1 [L,R=301]
#不加斜杠请求的地址是/wwwroot/jbxue.com/news/
RewriteCond %{HTTP_HOST} ^jbxue.com [NC]
RewriteRule (.*)$ http://bbs.it-home.org/news/$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^192.168.8.88 [NC]
RewriteRule com(.*)$ http://bbs.it-home.org$1 [L,R=301]

RewriteCond %{HTTP_HOST} ^192.168.8.88 [NC]
RewriteRule (.*)$ http://bbs.it-home.org/news/$1 [L,R=301]


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn