redirecting w., ww., wwww. to -> www

喜欢而已 提交于 2019-12-07 19:49:45

问题


I'm trying to redirect site.com w.site.com ww.site.com and wwww.site.com to www.site.com.

My boss wants to ensure typos make it to the site as well.

They redirect fine. I'm using ASP.Net and throw a 301 redirect back using a regular expression, however, tools such as http://www.seoconsultants.com/tools/headers.asp don't seem to show a correct redirect when I try to use w.site.com ww. etc.

I'm trying to figure out what google sees, but I'm not sure where to check.

It would "appear" that firebug reports it as a 301, but I can't figure out why these tools are reporting back the wrong information. My boss is using web tools to see if these work, so does anyone know a way to prove that a 301 is being sent back correctly. Or can anyone recommend a way I can check for myself if a proper 301 is being returned?


回答1:


Add a * A record to your dns entry. Yes that is an asterisk. This will cause anything that is not explicitly defined to go to that IP.

For example: *.site.com




回答2:


If you have access to your domain registrar you can change the CNAME record to point to the correct domain. This is the same thing as setting up a sub domain using DNS but in this case wwww or w both point to www on your website. From a design point of view you are also offloading the work of the redirect to another server.




回答3:


Try using the Live HTTP Headers plugin for Firefox to examine the headers the server sends back to you. If Live HTTP Headers reports a 301 redirect, try capturing the user agent on the server side and change your Firefox to use that user agent. If you still get a 301 redirect, you will have to examine the server more closely to see if the request from SEO Consultants is reaching the code around the redirect.

You can also try using IIS and adding a bunch of redirection websites that respond to the w, ww, and wwww subdomains instead of using global.asax and redirection there.




回答4:


If you have access to a Unix-type box, you can type this to see the returned headers:

curl -I ww.site.com

But I'd trust Firebug if I were you.




回答5:


Might try using IIS instead just to see if that quells the SEO tools.




回答6:


Use Fiddler to directly view the headers being sent back from the web server (and much much more - Fiddler is a tool that every web developer should have on hand, and it's free).

Google Webmaster Tools will report on 404's and other errors that Google hits while crawling your site. You can also set your preferred canonical domain name format (www.site.com vs. site.com).

Google is only going to "see" one of your redirects from a malformed URL (e.g. from w.site.com to www.site.com) if a malformed link actually exists somewhere that Google would attempt to crawl. I suppose you could put some test links somewhere unobtrusive on your site, check Google Webmaster Tools to see what Google does when it crawls those test links, and then delete the test links when you're satisfied with the results. Google's crawls are non-deterministic, so you might have to wait weeks before Google crawls those test links.



来源:https://stackoverflow.com/questions/459711/redirecting-w-ww-wwww-to-www

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!