0
我想重定向到http://example.com
http://www.example.com
永久重定向:如何管理301重定向域名
我尝试在我的.htaccess:
RedirectPermanent http://example.com http://www.example.com
它不工作。 我该如何解决这个问题?
我想重定向到http://example.com
http://www.example.com
永久重定向:如何管理301重定向域名
我尝试在我的.htaccess:
RedirectPermanent http://example.com http://www.example.com
它不工作。 我该如何解决这个问题?
的方法有很多,但我会解释一下其中的一些:
1.使用重写规则模块重定向 - mod_rewrite的:
选项+的FollowSymLinks
RewriteEngine叙述在
RewriteCond%{HTTP_HOST}^domain.com $ [NC]
重写规则^(。*)$ http://www.domain.com/ $ 1 [R = 301,L]
或
RewriteEngine叙述在
的RewriteCond%{HTTP_HOST} ^!万维网。(。*) [NC]
重写规则^(。*)$ http://www.%1/ $ 1 [R = 301,L]
个2.使用重定向脚本:
PHP重定向:
<?php
header(“HTTP/1.1 301 Moved Permanently”);
header(“Location:
http://www.newdomain.ru/newdir/newpage.htm”);
exit();
?>
ASP.NET重定向:
<script runat=“server”>
private void Page_Load(object sender, System.EventArgs e)
{
Response.Status = “301 Moved Permanently”;
Response.AddHeader(“Location”,“http://www.new-url.com”);
}
</script>
Ruby on Rails的:
def old_action
headers[“Status”] = “301 Moved Permanently”
redirect_to “http://www.new-url.com/”
end
*如果您需要更多信息,请写下我!
致敬*
RewriteRule很棒!谢谢 ! – Didav