我想允许访问目录,同时仍然保持当前配置。
当前配置如下:
DirectoryIndex index.php Index.php
Options +FollowSymLinks -MultiViews
#Turn mow_rewrite on
RewriteEngine On
RewriteBase /
## hiding .php extensions, and externally redirecting /dir/file.php to dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]
##internally redirecting /dir/file.php to dir/file
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]
问题是,这个htaccess当前配置会从文件中删除.php扩展名, 但我认为,这会影响目录,并限制对它的访问。
请问我该怎么做才能解决这个问题
答案 0 :(得分:0)
试试这段代码:
DirectoryIndex index.php Index.php
Options +FollowSymLinks -MultiViews
#Turn mow_rewrite on
RewriteEngine On
RewriteBase /
## hiding .php extensions, and externally redirecting /dir/file.php to dir/file
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NE]
##internally redirecting /dir/file.php to dir/file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]