apache .htcaccess 仅将根 ("/") 重定向到子文件夹
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2220028/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.htcaccess redirect ONLY root ("/") to sub folder
提问by Chris Harrison
I have a site that is arranged thus:
我有一个这样安排的网站:
/about
/关于
/css/
/CSS/
/index/index.php
/index/index.php
/js/
/js/
/index.php
/index.php
index.php uses a PHP redirect to index/index.php
index.php 使用 PHP 重定向到 index/index.php
I want to create a .htaccess rewrite rule so that when the root is accessed, /index/index.php is displayed BUT /about etc. stays the same.
我想创建一个 .htaccess 重写规则,以便在访问根目录时,显示 /index/index.php 但 /about 等保持不变。
回答by Sionide21
If you have mod_rewrite this should work:
如果你有 mod_rewrite 这应该工作:
RewriteEngine on
RewriteRule ^$ /index/index.php [L]
That will only match / (which it sees as empty) and internally redirect to /index/index.php
那只会匹配 / (它认为是空的)并在内部重定向到 /index/index.php
回答by Sionide21
The following will make / display index/index.php as its index file
以下将使/显示 index/index.php 作为其索引文件
DirectoryIndex index/index.php
Just put it in the .htaccess for /
把它放在 .htaccess for /

