0

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.

/var/www/html/.htaccess (root)

# 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

/var/www/html/manage/.htaccess (Sub-directory)

# 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?

2
  • I'd guess that you have to put your rules to handle the manage subdirectory in root above the WordPress rules so they get parsed first.
    – Milo
    Sep 5, 2015 at 4:10
  • Can you tell me how to do that? Sep 5, 2015 at 7:21

2 Answers 2

0

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.

2
0

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

Your Answer

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

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