user812120
user812120

Reputation: 585

PHP file in WordPress Directory

I have created a folder within WordPress public_html folder and created a test.php file in it as below.

www.mysite.com/myfolder/test.php

When I navigate to this url, I get page not found 404 error. All other files in myfolder, e.g. test.txt load without any issues. It's just php files that are not running. Could anyone please help?

My .htaccess file is

# 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

Upvotes: 0

Views: 177

Answers (3)

Arvind Pal
Arvind Pal

Reputation: 533

Please check file-folder permission of myfolder. It should not be 777 instead it should be 755 on your server.

Please refer Wordpress php file execution

Upvotes: 0

anubhava
anubhava

Reputation: 785098

This is weird since WP leaves your files alone due to RewriteCond %{REQUEST_FILENAME} !-f condition.

Try creating a myfolder/.htaccess file with this line:

# just one line here
RewriteEngine On

This will basically nullify all rewrite rules of parent folder.

Upvotes: 1

Phil Perry
Phil Perry

Reputation: 2130

WordPress has its own .htaccess that is probably treating your URI as some sort of "Search Engine Friendly" thing, and translating it into some other format that WP is expecting. For example, http://www.mysite.com/myfolder/test.php might get rewritten to something like http://www.mysite.com/myfolder/index.php?target=test%25php. That would give a 404 error from within WP (not a real server 404 error). Perhaps something can be done from within WP's configuration, or you could modify the .htaccess to tell it specifically not to rewrite test.php.

Upvotes: 1

Related Questions