To run non-WordPress PHP files in a subfolder alongside a WordPress installation, follow these steps to modify your .htaccess
file:
-
Choose a Subfolder Name: Decide the name for your subfolder, e.g.,
mycustomphp
. -
Modify the .htaccess File: Add the following lines above the
# BEGIN WordPress
section to exclude your subfolder from WordPress’s URL rewriting:RewriteEngine On RewriteRule ^mycustomphp/ - [L]
Ensure the entire .htaccess looks like this:
RewriteEngine On RewriteRule ^mycustomphp/ - [L] # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
This approach allows your PHP files to operate separately from the WordPress environment without altering core rewrite rules that could affect your main site.