Access Standalone PHP File With Wordpress Installe

2019-09-06 13:04发布

问题:

I have just installed wordpress on a site. However, I have some standalone php files that I use for analyzing database data on the site that now return a 404 when trying to access them.

For example:

www.mywordpresssite.com/myscripts/myscript.php

This returns a 404.

Here is my .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>

Is there any way I can achieve normal access to the said directory/file but without upsetting the current functionality of Wordpress?

Thanks a lot

回答1:

Change your .htaccess file to this

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

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/myscripts/(.*)$ [OR]
    RewriteRule ^.*$ - [L]
    </IfModule>


标签: php wordpress