[英]htaccess redirect all files in the root directory to coresponding pages in subdirectory
我有几页
http://localhost/template
比如home.php,about.php,contact.php
在http://localhost/template/sr
我有相同名称的页面。
这就是我在root .htaccess文件中的内容
RewriteEngine on
RedirectMatch 301 ^/$ http://localhost/template/sr/
我的error.log文件报告:
[localhost/sid#923dd8][rid#dd70b0/initial] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/
[localhost/sid#923dd8][rid#ddd0c8/subreq] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/index.php
[localhost/sid#923dd8][rid#ddb0c0/initial] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/
[localhost/sid#923dd8][rid#ddd0c8/subreq] [perdir C:/xampp/htdocs/template/] pass through C:/xampp/htdocs/template/index.php
此设置不重定向我继续从根目录获取页面。
如果您尝试将页面重定向到子目录中的相应页面:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^([^/]+)/?$ /template/sr/$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.