I have a subdomain which redirects to a specific directory address. How can I disable that directory address if it is accessed directly?
i.e. sub.domain.com
redirects to domain.com/sub
. When I access domain.com/sub
directly it should redirect to error 404.
Thanks
When I access domain.com/sub directly it should redirect to error 404.
You can use this rule as first rule in sub/.htaccess
:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^sub\. [NC]
RewriteRule ^ - [L,R=404]
In htaccess in your document root, add this :
RewriteEngine on
RewriteCond %{HTTP_HOST} !^sub.domain.com$
RewriteRule ^folder - [R=404,L]
This will redirect all requests that start with /folder to 404 page if requested host is not sub.domain.com .