How to set WordPress to ignore a file path?

If you use WordPress then, in some cases, you need to allow access to a file directory but don't require a subdomain. For example, if you upload a file or a folder to your root directory (i.e. public_html directory), then WordPress may show a 404 error while attempting to access its file path. In situations like this, you can create a rewrite condition within your .htaccess file. This will force your website to ignore the path of that file. Now, it will allow a file- for example, yourdomainname.com/file.html- to display as it is, instead of embedded as a part of the parent WordPress website. 

How to  set WordPress to ignore a file path

1. First, log in to your account via cPanel or SSH.                                                            
2. Navigate to your WordPress directory.                                                                     
3. Then, open your website's .htaccess file.                                                                 
4. The default .htaccess file will look like below:                                                     

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress



Add the code given below above the RewriteCond lines. You have to replace 'file' with the file path to your saved files:                                                               

RewriteCond $1 !^(/file)

 5. At last, save all the changes that you have made.

Did you find this article useful?