2013-02-10 51 views
1

我的WordPress安装在我的根目录下,它的htaccess重写规则阻止我访问example.com/file.php,而是重定向到/从htaccess重写规则中排除特定文件

我想从重写规则中排除该特定文件。

现有的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

您需要添加

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] 
+0

不过重定向:/ – developdaly 2013-02-10 16:36:56

+0

尽我editted答案。如果这不起作用 - 尝试chaning /index.php到index.php(即删除/) – Laurence 2013-02-10 16:39:15

+0

不行。我以不同的顺序移动了'file.php'这一行,并且没有预先加入'index.php'斜线。任何其他想法? – developdaly 2013-02-10 16:47:08