HTACCESS显示目录列表重写模式不起作用



我目前正在使用这些重写模式htacess ...它们运行良好,可以显示http://domain/usernamehttp://domain/post?id=123

问题

当我在浏览器上输入时,可以看到我的网站目录...

includes/?  (http://localhot/includes/?)
account/?    (http://localhot/account/?)

我不希望看到它们。...这是通过在该特定目录中添加index.php来解决的。...但是我无法处理所有索引页面。...

如何在htaccess中进行修复?

htaccess

#post
RewriteRule ^post/?$ account.php?p=post [L,NC,QSA] 
#user
RewriteRule ^([a-zA-Z0-9._-]+)/?$ account.php?p=profile&username=$1 [L,QSA]

您可以添加此指令:

Options -Indexes

在您的.htaccess顶部禁止目录列表。

Options -Indexes
RewriteEngine On
#post
RewriteRule ^post/?$ account.php?p=post [L,NC,QSA]
# add trailing slash if missing from directories    
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule [^/]$ %{REQUEST_URI}/ [L]
#user
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([w-]+)/?$ account.php?p=profile&username=$1 [L,QSA]

最新更新