Forum Moderators: phranque
for example a site with a subdomain can be accessed from following pages:
1.
www.mydomain.com/subdomain/somepage.html
2.
subdomain.mydomain.com/somepage.html
3.
www.subdomain.mydomain.com/somepage.html
4.
***.***.***.***/subdomain/somepage.html (*** = ip adress of hosted site)
5.
mydomain.com/subdomain/somepage.html
Is there a proper way to avoid the same?
Is there a proper way to check/confirm if pages are available only via 1 URL and not all of above?
thanks.
You can check that the HTTP_HOST matches what you expect, and if it wrong, redirect the user. You will still be accessible using all these incorrect methods - but the visitor to that address will just get redirected to the right address.
I have also solved the same problem using PHP before with great success. Be aware with PHP you need to place your domain/host/path checking code at the top of every page (!)
Regards,