简体   繁体   English

htaccess将索引文件夹重写为php文件

[英]htaccess rewrite index folder to php file

Here is my folder structure 这是我的文件夹结构

test
-.htaccess
-app
--index.php

I want when I go to http://localhost/test/ , it rewrite to test/app/index.php (no redirect) 我想在访问http:// localhost / test /时将其重写为test / app / index.php(无重定向)

My htaccess below. 我的htaccess在下面。 Now it work fine with url http://localhost/test/some/thing . 现在可以正常使用url http:// localhost / test / some / thing With url http://localhost/test/ , it still show files index of folder test 使用url http:// localhost / test / ,它仍然显示文件夹test的文件索引

<IfModule mod_rewrite.c>
RewriteBase /test/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /test/app/index.php [L]
</IfModule>

The rewrite rule is expressed in regexp, so wouldn't that make your dot an any character match? 重写规则以regexp表示,所以这不会使您的点成为任何字符匹配吗? Did you try this: 您是否尝试过:

RewriteRule ^/$ app/index.php [L]

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

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