开发者

How do i test www to non-www forwarding?

I'm using html5 boilerplate and I'm trying to test if my htaccess is working properly. When I type in www.domain.com into chrome or firefox it does not redirect. I'm thinking maybe this is just some browser gimmick though, similar to how Chrome hides the http:// even though its there.

I have checked using chrome dev tools and firebug, and under the request headers it shows whatever I enter in as the "Host"... both with www. and without it... so I dont really know if its working

# ----------------------------开发者_如何学JAVA------------------------------------------
# Suppress or force the "www." at the beginning of URLs
# ----------------------------------------------------------------------

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>


The rule is OK.

Please check the following:

  • Did you enabled mod_rewrite in your .htaccess via RewriteEngine On?
  • Is mod_rewrite module loaded in Apache at all? Try moving your instructions outside of <IfModule mod_rewrite.c> to see if it will generate any server errors (indication that mod_rewrite is not loaded).
  • Check if .htaccess is allowed to be used.

As to www or non -- see these topics on Webmasters part of StackExchange:

  • https://webmasters.stackexchange.com/questions/507/should-i-include-www-in-my-canonical-urls-what-are-the-pros-and-cons
  • https://webmasters.stackexchange.com/questions/11925/to-www-or-not-to-www
  • https://webmasters.stackexchange.com/questions/14457/what-does-www-do
  • https://webmasters.stackexchange.com/questions/11560/seo-preference-for-www-or-http-protocol-redirection-do-www-websites-rank-bett
  • https://webmasters.stackexchange.com/questions/8964/is-was-seo-the-only-reason-to-force-the-www-on-domain-names
  • https://webmasters.stackexchange.com/questions/15290/does-it-matter-that-our-website-cant-be-found-without-the-www
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜