我在我的root中安装了WordPress,其htaccess重写规则阻止我访问example.com/file.php
,而是重定向到/
。
我想从重写规则中排除一个特定文件。
现有的htaccess:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
答案 0 :(得分:0)
您需要添加
RewriteCond $1 !^(file\.php)
即
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteCond $1 !^(file\.php) [L]
RewriteRule ^(.*)$ /index.php/$1 [L]