WordPress.org

Support

Support » How-To and Troubleshooting » Cannot access any PHP files directly – results in 404 message

Cannot access any PHP files directly – results in 404 message

  • I have tried everything, but just can’t figure it out.

    I am trying to make the timthumb.php file work, but I just can’t access the file on my server through the absolute URL. In fact, I can’t access any PHP file in the root directory that WordPress is installed in other than index.php. Accessing any other php files in the root which I know are there (e.g., header.php, footer.php) all result in WordPress throwing a 404 error message.

    I’m sure this is something simple, but I just can’t understand why WordPress won’t open a PHP file which exists and instead throws 404 error messages. Browsing the blog through categories, search, posts all works fine.

    Please help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Your theme files– “(e.g., header.php, footer.php)”– aren’t in the root directory. They are in wp-content/themes/<theme-name>. It only looks like they are in root because of the URL rewriting that WP performs. You can’t access any of them directly without navigating to the theme directory (or probably but I haven’t tired it, manipulating WP url rewriting). So, this will not work: http://blogname/header.php. This will work: http://blogname/wp-content/themes/<theme-name>/header.php. You know you’ve found the file because it will throw an error, at least with some (many) setups.

    What if you needed to access a different php file in a directory in WP as root but the file was in a separate directory, it throws a 404.

    So as an example:

    Root/folder1/file.php and WP throws a 404

    How do you tell WP to allow access to php files which are stored in a separate directory in the WP install directory which is in Root?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cannot access any PHP files directly – results in 404 message’ is closed to new replies.