I have wordpress installed on my root (/var/www/html
) and I have a sub-directory in the root as /var/www/html/manage
Both directories have it's own .htaccess
files. Content of the .htaccess
are as follows.
# 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
# Start Manage .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
ErrorDocument 404 /lost.php
# End Manage .htaccess
I can rewrite .php
extension of the the php
files in the sub-directory with the .htaccess but I cannot use custom 404 as defined in the htaccess file in the sub-directory. When I go to www.example/manage/laksjdflskjf
it shows wordpress 404 instead of lost.php
How Can I make the sub-directory to show its 404 instead of wordpress 404?
I have wordpress installed on my root (/var/www/html
) and I have a sub-directory in the root as /var/www/html/manage
Both directories have it's own .htaccess
files. Content of the .htaccess
are as follows.
# 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
# Start Manage .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
ErrorDocument 404 /lost.php
# End Manage .htaccess
I can rewrite .php
extension of the the php
files in the sub-directory with the .htaccess but I cannot use custom 404 as defined in the htaccess file in the sub-directory. When I go to www.example.com/manage/laksjdflskjf
it shows wordpress 404 instead of lost.php
How Can I make the sub-directory to show its 404 instead of wordpress 404?
The way the wordpress htaccess works is that first it looks if there is a file matching the request location, in which case it is being "run", otherwise the wordpress handles the URl. Basically you don't even "execute" your subdirectory's htaccess unless you access an existing fie there.
What you should do is to add to the wordpress htaccess rules that will prevent it from handling urls under the subdirectory.
WordPress has its own 404.php file in theme.
WordPress will automatically use that page if a Page Not Found error occurs
You need to edit this file or if your theme don't have this file then you need to create it.
For more detail go to this link