Wordpress重写规则与实际路径和文件名冲突

时间:2014-12-03 04:53:27

标签: php wordpress apache .htaccess mod-rewrite

我正在重新创建我的雇主网站,它目前使用WordPress,

我在名为dev的/ public_html /文件夹中创建了一个新目录。 dev文件夹为空时 - 它将按预期显示目录内容。我在那里抛出index.php文件的那一刻,我收到了404错误。

index.php的内容只是<h1>Working</h1>

查看主目录的.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

如果请求的文件名实际上是真实的文件或目录,它似乎应该已经忽略了规则。

整个.htaccess文件。

RewriteEngine on

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
#The next line modified by DenyIP
order allow,deny
#The next line modified by DenyIP
#deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName ant.com.au

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

<Files 403.shtml>
order allow,deny
allow from all
</Files>

看起来似乎没有任何冲突试图导航到文字目录和/或文件

非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

这实际上非常简单:

我刚刚添加了重写条件:RewriteCond %{REQUEST_URI} !^/dev/

完全重写:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/dev/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
相关问题