Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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 mod_重写重定向替代方案_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache mod_重写重定向替代方案

Apache mod_重写重定向替代方案,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我正在使用: 重定向301/ 问题是它将第一个域的结尾追加到新域 我需要一个替代方案,将所有请求重定向到新域,而不附加/后面的内容。您可以使用mod_别名,其语法如下: Redirect /something http://www.example.com/new_something 如果您需要更复杂的东西,mod_alias有更多的选项和命令,请选中,或者在.htaccess中使用类似的选项 RewriteEngine On RewriteBase / Rewr

我正在使用:

重定向301/

问题是它将第一个域的结尾追加到新域


我需要一个替代方案,将所有请求重定向到新域,而不附加/

后面的内容。您可以使用mod_别名,其语法如下:

Redirect /something http://www.example.com/new_something

如果您需要更复杂的东西,mod_alias有更多的选项和命令,请选中,或者在.htaccess中使用类似的选项

RewriteEngine On
        RewriteBase /
        RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
        RewriteRule ^(.*)$ http://newexample.com/$1 [L,R=301]
试试这个

RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.oldsite\.com$
RewriteRule ^(.*)$ http://www.newsite.com/ [L,R=301]

假设
newdomain.com
指向一个新的IP/主机。您可以使用
RedirectMatch
而不是
Redirect
来实现其正则表达式功能:

RedirectMatch 302 ^ http://newdomain.com