I have a WordPress instance running on my domain's root.

One WordPress page is located at www.example.com/product/. I placed some static HTML files in a path below that so that visitors can go to www.example.com/product/documentation/ where an index.html and other HTML files live.

Now I can access the static HTML files just fine, but when going to the WordPress site (i.e. www.example.com/product/), I get a 403 Forbidden error.

How can I make the static HTML files available at that URL while retaining access to the WordPress page?

Here is my .htaccess file (I think it is the unmodified default)

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress

Sorry if this question has been answered already, but I have only found questions about problems with displaying the static content rather than the WordPress content.

  • what is your htaccess? Aug 18, 2017 at 8:28
  • I've edited the question to include the .htaccess file Aug 18, 2017 at 8:36
  • there are two things that can be done. 1. change the htaccess so it will load wordpress for the explicit products/ path but not below it or 2. add a page template that send the file on the server based on the page url, and create and configure the pages to the correct url. Hopefully someone will make proper answer from this, or maybe have a better idea ;) Aug 18, 2017 at 8:42

1 Answer 1


By creating a physical directory the same as a (virtual) WordPress URL you have created a conflict. The URL needs to be routed through WP, but the default front-controller (the .htaccess code shown above) specifically excludes physical directories from being rewritten.

The 403 Forbidden error comes about because you don't have a directory index document (eg. index.html or index.php) in the /product subdirectory. (And neither do you want one, just in case you were wondering.)

Depending on your site, you could simply remove the directory check in the front controller. For example (just commented out):

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

This will mean that requests for any physical directories (just the bare directory) will not be accessible, they will be passed through WP. However, this will likely conflict with your /product/documentation/ URL. In which case, you can add something like the following before the above directives:

RewriteRule ^product/documentation/$ /product/documentation/index.html [L]

(Otherwise, you'll get a WordPress 404 if any physical directory is requested, where the URL does not exist in WP.)

Alternatively, you can explicitly make an exception for this one subdirectory and manually route it through WP (ie. rewrite it to index.php). For example, before the existing front controller (at the top of the file), add the following:

RewriteRule ^product/?$ /index.php [L]
  • Thanks. This seems to work. However, I had to to change the last RewriteRule to RewriteRule ^product/documentation/?$ /product/documentation/index.html [L]. Can you update your answer? I would also like to know if there is some caveat to this approach beyond the necessity of manual updates to the .htaccess file? Is there some security risk? Aug 21, 2017 at 11:13
  • You should only need to add that RewriteRule if you have removed the directory check in the WordPress front controller (however, the trailing ? on the regex should be omitted if the URLs should have a trailing slash - as in your question). I've updated my answer. However, if you used the "alternative" method in the last part of my answer, that shouldn't be required. (?)
    – MrWhite
    Aug 21, 2017 at 16:29
  • This alone shouldn't result in a "security risk". Requests for directories will now be routed through WP (assuming that is how you've chosen to do it), which will likely result in a 404, rather than a 403 (Apache default assuming directory indexes are not enabled) or 200 OK and an empty response - which is often the default behaviour with WP (if you have a blank index document in that directory).
    – MrWhite
    Aug 21, 2017 at 16:32
  • I've noticed a problem. When commenting out the line RewriteCond %{REQUEST_FILENAME} !-d, this breaks the wp-admin URL www.example.org/wp-admin/. I am getting a ERR_TOO_MANY_REDIRECTS error. This does not affect sub URLs like www.example.org/wp-admin/edit.php. Aug 22, 2017 at 12:11
  • It may be preferable to just make an exception for the /product/ URL, as mentioned in the last part of my answer (if you do this, then you don't remove the directory check and nor would you need to rewrite /product/documentation/). Otherwise, you'll need to make another exception for the /wp-admin URL, like you have done for your /product/documentation/ URL and manually rewrite to the document index (in this case index.php, not index.html). eg. RewriteRule ^wp-admin/?$ /wp-admin/index.php [L] (which needs to go before the WP front controller).
    – MrWhite
    Aug 22, 2017 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.