Mobile app version of vmapp.org
Login or Join
Eichhorn148

: Subdomain htaccess rules I have the following .htaccess in my root: DirectoryIndex index.html index.php Options +Indexes # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule

@Eichhorn148

Posted in: #Apache #Htaccess #ModRewrite

I have the following .htaccess in my root:

DirectoryIndex index.html index.php
Options +Indexes

# 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


I want to add the following rule for everything under the /account folder:

ErrorDocument 404 /error.php


I believe it should start with RewriteCond %{REQUEST_URI} !^/account but I'm not sure how to write the actual rule nor where in the document to add this.

Any help is much appreciated.

EDIT: I tried in /account/.htaccess :

ErrorDocument 404 /error.php

# Enable the rewrite engine in the subdirectory to prevent
# mod_write directives in the parent .htaccess file being executed.
RewriteEngine On
RewriteOptions inherit

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Eichhorn148

1 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

If the /account subfolder is intended to be outside of WordPress then you can do something like closetnoc suggests, however, you also need to enable the rewrite engine to prevent the WordPress rewrites in the parent .htaccess from taking over.

So, in /account/.htaccess:

ErrorDocument 404 /error.php

# Enable the rewrite engine in the subdirectory to prevent
# mod_write directives in the parent .htaccess file being executed.
RewriteEngine On


Simply enabling the rewrite engine in the subdirectory will prevent mod_write directives in the parent .htaccess file being executed. Since mod_rewrite directives are not inherited by default. In order to "inherit" parent directives you would need to explicitly call: RewriteOptions inherit.

The fact that it's a subdomain doesn't really make a difference in this respect.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme