Exclude a specific file from htaccess rewrite rules

I have WordPress installed in my root and its htaccess rewrite rules are preventing me from accessing example.com/file.php and instead redirects to /.

I want to exclude that one specific file from rewrite rules.

Read More

Existing htaccess:

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*.php)$ $1 [L]
RewriteRule . index.php [L]

Related posts

Leave a Reply

1 comment

  1. You need to add

    RewriteCond $1 !^(file.php)
    

    i.e.

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
    RewriteCond $1 !^(file.php) [L]
    RewriteRule ^(.*)$ /index.php/$1 [L]