redirect - Override 404 when navigating to single php file

admin2025-01-07  5

I uploaded a php file in the root directory of my Wordpress site that I need to be able to access directly through the browser.

When I do, it looks like Wordpress takes over, triggers a 404, and shows the error page.

It only occurs for php files that are one level down from root. I tried viewing a php file in root and it works. I tried with html and txt files in root and in "folder" and I can view them just fine. However when the php file is within "folder" and I try viewing, I get a 404.

Any ideas on what's going on? How can I prevent this from happening?

The structure is this

/root
.../folder
....../file-that-throws-404.php
.../wp-admin
.../wp-content
.
.
.

I uploaded a php file in the root directory of my Wordpress site that I need to be able to access directly through the browser.

When I do, it looks like Wordpress takes over, triggers a 404, and shows the error page.

It only occurs for php files that are one level down from root. I tried viewing a php file in root and it works. I tried with html and txt files in root and in "folder" and I can view them just fine. However when the php file is within "folder" and I try viewing, I get a 404.

Any ideas on what's going on? How can I prevent this from happening?

The structure is this

/root
.../folder
....../file-that-throws-404.php
.../wp-admin
.../wp-content
.
.
.

Share Improve this question edited May 12, 2017 at 21:48 Christian Aziz asked May 12, 2017 at 21:37 Christian AzizChristian Aziz 12 bronze badges 1
  • This isn't the behavior of a default WordPress install, there aren't any rules that would prevent a physical file from loading at any level in hierarchy. – Milo Commented May 12, 2017 at 21:52
Add a comment  | 

2 Answers 2

Reset to default 0

WordPress .htaccess should fix this. It checks wether the file exists before doing any redirects. Are you sure your installation is correct?

This was actually a symptom of incorrect permissions that I set on the folder and PHP files. Apologies for incorrectly diagnosing WP as the culprit. All is well now.

PHP files must be set to 644. Folders containing them must be set to 755.

This is the post that led me there: https://stackoverflow.com/a/34303324

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736254403a202.html

最新回复(0)