开发者

How to Redirect http://example.com to http://www.example.com

How to Redirect http://example.com to http:开发者_Go百科//www.example.com using htaccess


use a .htaccess file with following content:

RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

In case of IIS make sure, that the host listens to all urls you want to use for your block (including www.example.com and example.com)

Then use the rewrite module of the IIS:
http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module

You can easily import rules from Apache mod_rewrite into ISS:
http://learn.iis.net/page.aspx/470/importing-apache-modrewrite-rules


By having a correct configured DNS. Make sure you have following line:

@      IN A   your.server.ip.address

Which says anyone requesting yourdomain.bla will be sent to the server with the given IP. In your case, the IP-address would be the same as the CNAME configuration for "www".

Though, if you use a web hotel service they are too often not letting the customer make a default config. It might be then that you're not able to make the config needed.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜