dongre6073 2014-12-03 04:53
浏览 32
已采纳

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

I'm recreating my employers website, it currently uses WordPress,

I have created a new directory within the /public_html/ folder named dev. While the dev folder is empty - It will display directory contents as expected. The moment I throw an index.php file in there, I get sent back to a 404 error.

The contents of index.php is simply <h1>Working</h1>

Looking into the .htaccess of the primary directory

# 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>

It appears that it should already be ignoring the rule if the requested filename is infact a real file or directory.

The entire .htaccess file.

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>

Definitely looks like there should be no conflict whatsoever trying to navigate to a literal directory and/or file

Any help is greatly appreciated

  • 写回答

1条回答 默认 最新

  • doubeng9407 2014-12-10 23:20
    关注

    This was actually very simple to fix:

    I just added a rewrite condition: RewriteCond %{REQUEST_URI} !^/dev/

    Full rewrite:

    <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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?