I have found a lot of information how to redirect example.com to www.example.com . Two methods DNS and .htaccess
. The problem is that most answers do not provide hosting service type and seems different people recommend different option. I know .htaccess
is no brainer for Shared Hosting.
Does anybody know which method is better for VPS ?
In order of least to most advisable places to issue an HTTP 30X:
.htaccess
.htaccess
at all if you can avoid it . Very Late Edit:
I'd like to add that performing redirects in the application code is not necessarily a bad thing, but for simple www.
and other host/infrastructure-level redirects the simplicity can't be beat.
eg: foo.com
to www.foo.com
and :80
to :443
However , if you're also doing application redirects you need to have a bulletproof division between what redirects are handled by the the server and which are handled by the application. Otherwise you can descend into a circle of hell where the application and server disagree on how to redirect.
If that division is anything less than absolute then you're probably better off simply letting the application manage redirects entirely.
These types of suggest
questions are frowned upon, but, the domain registry should handle both WWW and non-WWW domain names. Then at your server, you can choose to respond to both, or 301 redirect one to another via htaccess
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.