Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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
Apache 如何重定向我的主页?_Apache_.htaccess_Redirect - Fatal编程技术网

Apache 如何重定向我的主页?

Apache 如何重定向我的主页?,apache,.htaccess,redirect,Apache,.htaccess,Redirect,我切换了URL,并将每个页面重定向到新站点上的相应页面。我的站点相对较小,所以我只对每个页面使用重定向301/。我已经到了为除主页之外的所有页面设置重定向301/的地步。例如: Redirect 301 /blog http://newsite.com/blog Redirect 301 /page-name http://newsite.com/page-name 对于我尝试使用的主页: Redirect 301 / http://newsite.com 这是可行的,除了它将我旧站点上的每

我切换了URL,并将每个页面重定向到新站点上的相应页面。我的站点相对较小,所以我只对每个页面使用重定向301/。我已经到了为除主页之外的所有页面设置重定向301/的地步。例如:

Redirect 301 /blog http://newsite.com/blog
Redirect 301 /page-name http://newsite.com/page-name
对于我尝试使用的主页:

Redirect 301 / http://newsite.com
这是可行的,除了它将我旧站点上的每个页面重定向到主页,并覆盖我设置的所有其他301重定向

我想这相当简单,但我在谷歌上找不到任何东西。另外,如果301重定向设置不正确,请告诉我


谢谢

您需要使用
RedirectMatch
指令将此链接指向特定的URL

RedirectMatch 301 ^/$ http://newsite.com
RedirectMatch
支持正则表达式,而不是
Redirect