简体   繁体   中英

http:// vs http://www: Should I use subdomain or permanent redirect

As far as I can work out, http://www.example.com is technically a subdomain of http://example.com .

Is it better to have www.example.com as a separate subdomain (pointing at the same content), or is it better to do a perminent redirect of all traffic from http://example.com to www.example.com (or visa versa)?

Excuse my ignorance, but the reason I ask is that I'm worried that having two locations online (one with the www, one without ), could cause problems with SEO, cookies, analytics etc.

Thanks!

G

Yes, if it is the same content, then give it a single URI; and redirect example.com -> www.example.com not the other way around (www. is the convention and is where systems will most likely look first). If you host on both urls, then Spiders and other bots may be smart enough to realize that it is the same, but why rely on it when a simple redirect ensures they know?

This also means a slightly simple web server setup (only hosting a single domain) and will be easier down the road if you do things like enable ssl or load balancing.

The only (arguable) downside to redirects is that it will mean an additional http request if the user gets it wrong.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM