从非www重定向到www

编程入门 行业动态 更新时间:2024-10-24 21:25:18
本文介绍了从非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

本文发布于:2023-07-16 03:46:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117510.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   www

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!