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]