Reputation: 1981
I have a website which can be accessible via sub-domains as well. e.g
www.example.com, abc.example.com and xyz.example.com
all three domains points to the same website. The website behaves differently for all 3 domains. Now my problem is I want to restrict access to About Us page and What We Do pages when they are accessed via sub-domains. I know I can do a redirect from PHP but I want to restrict even before the request goes to PHP like in htaccess or vhost file itself. So
www.example.com/aboutus - Must work BUT
abc.example.com/aboutus and xyz.example.com/aboutus - must not work
I tried to search a lot on web but couldn't find a solution.
Please help
Thanks in Advance
Upvotes: 0
Views: 176
Reputation: 4715
If you have mod_rewrite you could do:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteRule /aboutus http://www.example.com/errorpage [R,L]
That looks for any host not being www.example.com if the url /aboutus is called. For further information see this docu
Upvotes: 1