Home >Backend Development >PHP Tutorial >Configuration code for htaccess 301 redirection in the secondary directory

Configuration code for htaccess 301 redirection in the secondary directory

WBOY
WBOYOriginal
2016-07-25 09:00:331184browse
二级目录下的页面,子目录下也存在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]


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn