Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Redirect 重定向永久:如何管理301重定向域名_Redirect - Fatal编程技术网

Redirect 重定向永久:如何管理301重定向域名

Redirect 重定向永久:如何管理301重定向域名,redirect,Redirect,我想重定向http://example.com至http://www.example.com 我已在.htaccess中尝试: RedirectPermanent http://example.com http://www.example.com 它不起作用。 如何解决这个问题?有很多方法,但我将向您解释其中的一些: 1。使用RewriteRule模块重定向-mod_rewrite: 选项+FollowSymLinks 重新启动发动机 RewriteCond%{HTTP_HOST}^domai

我想重定向
http://example.com
http://www.example.com

我已在.htaccess中尝试:

RedirectPermanent http://example.com http://www.example.com
它不起作用。
如何解决这个问题?

有很多方法,但我将向您解释其中的一些:

1。使用RewriteRule模块重定向-mod_rewrite:

选项+FollowSymLinks

重新启动发动机

RewriteCond%{HTTP_HOST}^domain.com$[NC]

重写规则^(.*)$$1[R=301,L]

重新启动发动机

重写cond%{HTTP_HOST}^www.(.*)[NC]

重写规则^(.*)$$1[R=301,L]

2。使用脚本重定向:

PHP重定向:

*如果你需要更多的信息,请写下来

致意*

 <?php 
header(“HTTP/1.1 301 Moved Permanently”); 
header(“Location:
http://www.newdomain.ru/newdir/newpage.htm”); 
exit(); 
?>
<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>
def old_action
headers[“Status”] = “301 Moved Permanently”
redirect_to “http://www.new-url.com/”
end