我的网站上有一个链接
x.icebreaker.com/products
和目录中的文件
x.icebreaker.com/products/bow
我有以下.htaccess
文件,允许在浏览器中删除文件扩展名,但是当有一个同名文件夹时,我无法显示页面(默认打开文件夹
x.icebreaker.com/products /
我该如何解决这个问题?
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
# Disable directory browsing
Options All -Indexes
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)/?$ $1.php
如果不清楚问题不在于如何让页面加载x.icebreaker.com/products
,那么如何获取 NOT 来加载x.icebreaker.com/products/
答案 0 :(得分:2)
您还需要禁用MultiViews
选项:
Options All -Indexes -MultiViews
MultiViews
使用选项Apache's content negotiation module
在 mod_rewrite
之前运行,并使Apache服务器匹配文件扩展名。因此/file
可以在网址中,但它会投放/file.php
。
同时使用此规则替换.php
添加规则:
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]