本文介绍了从非www重定向到www的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将我的网站从example重定向到www.example
I want to redirect my site from example to www.example
推荐答案Option 1: Redirecting example/dir/anypage.html to www.example/dir/anypage.html (same page) Use this format if you want a request for any URL at example to redirect to the same page at www.example. (If you want to redirect to the home page of www.example, see option 2 below.) RewriteEngine On RewriteCond %{HTTP_HOST} ^example [nocase] RewriteRule ^(.*) www.example/
1 [last,redirect = 301] 1 [last,redirect=301]
Option 2: Redirecting example/dir/anypage.html to the www.example home page Use this format if you want a request for any URL at example to redirect to the home page of www.example. (If you want to redirect to the same page at www.example, see option 1 above.) RewriteEngine On RewriteCond %{HTTP_HOST} ^example [nocase] RewriteRule ^(.*) www.example/ [last,redirect=301]
通过iis中的microsoft web platform安装程序安装url rewrite 2.0,并在Web配置文件中添加以下代码特定领域: Install url rewrite 2.0 via microsoft web platform installer in your iis and add the following code in the web config file of particular domain: <system.webserver> <rewrite> <rules> <rule name="Redirect domain to www" patternsyntax="Wildcard" stopprocessing="true"> <match url="*" /> <conditions logicalgrouping="MatchAny"> <add input="{HTTP_HOST}" pattern="abc" /> <add input="{HTTP_HOST}" pattern="ABC.COM" /> <add input="{HTTP_HOST}" pattern="Abc" /> <add input="{HTTP_HOST}" pattern="ABc" /> <add input="{HTTP_HOST}" pattern="aBc" /> </conditions> <action type="Redirect" url="www.abc/{R:0}" /> </rule> </rules> </rewrite> </system.webserver>
更多推荐
从非www重定向到www
发布评论