0

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
3
  • 1
    Where is your site hosted? With some hosting solutions, there are requirements on PHP files for them to be handled by PHP. One such restriction I came across was that the PHP files must not be readable by the group. Commented Nov 22, 2013 at 17:32
  • @anubhava WP is running fine. Commented Nov 23, 2013 at 6:22
  • Does the file have to be outside WP? Commented Nov 23, 2013 at 10:44

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.