I used Installatron to install Wordpress in a subdirectory of an existing PHP website, to add a blog to that website. My main website is administered via cPanel.
Here's my website directory structure:
/-- public_html
/-- .htaccess
/-- index.php
/-- about.php
/-- etc.
/-- product-pages
/-- index.php
/-- product-a.php
/-- product-b.php
/-- etc.
/-- blog
/-- wp-admin
/-- wp-content
/-- wp-includes
/-- .htaccess
/-- .user.ini
/-- index.php
/-- etc.
The Wordpress installation added the standard Wordpress section to the root .htaccess
:
# 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]
</IfModule>
# END WordPress
As many people have found, this disables my custom 404 error pages for the main website, displaying the site homepage instead. 404 errors for the Wordpress blog work as expected and display the Wordpress custom 404 error.
Wordpress also created a .htaccess
in its own /blog
installation directory. It includes this section:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
I found that by removing the Wordpress section from the .htaccess
in the main website root, both main website custom 404 and Wordpress custom 404 functionality appear to work correctly. Is there any reason why I shouldn't do this?
Is the addition of a Wordpress section to the root .htaccess
by the Installatron Wordpress installer incorrect behaviour for a subdirectory installation?