.htaccess显示当前目录的索引

时间:2018-02-01 18:00:34

标签: .htaccess mod-rewrite

我似乎无法访问demo目录index.html

我有这个网址:

http://127.0.0.1/test/facilities/demo/account

我希望它显示此页面index.html:

http://127.0.0.1/test/facilities/demo

但它显示了这个目录:

http://127.0.0.1/test/

这是我的.htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.html [L]

.htacces文件位于:

http://127.0.0.1/test/

谢谢!

1 个答案:

答案 0 :(得分:1)

You may be able to use this rule in test/.htaccess:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*/)?[^/]+/?$ $1index.html [L]