Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.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
Url 将多个域重定向到.htaccess中的一个域_Url_.htaccess_Redirect - Fatal编程技术网

Url 将多个域重定向到.htaccess中的一个域

Url 将多个域重定向到.htaccess中的一个域,url,.htaccess,redirect,Url,.htaccess,Redirect,我想在.htaccess中添加一些代码,以便将几个不同的域重定向到单个域。我见过一些代码可以在一个域中执行此操作,例如: RewriteCond %{HTTP_HOST} ^www\.example\.net RewriteRule (.*) http://www.example.com/$1 [R=permanent,QSA,L] 但是,将多个域重定向到单个域的最佳方法是什么?仅当域不是您要重定向到的域时才重定向: RewriteCond %{HTTP_HOST} !(^www\.exa

我想在.htaccess中添加一些代码,以便将几个不同的域重定向到单个域。我见过一些代码可以在一个域中执行此操作,例如:

RewriteCond %{HTTP_HOST} ^www\.example\.net  
RewriteRule (.*) http://www.example.com/$1 [R=permanent,QSA,L]

但是,将多个域重定向到单个域的最佳方法是什么?

仅当域不是您要重定向到的域时才重定向:

RewriteCond %{HTTP_HOST} !(^www\.example\.com$)  
RewriteRule (.*) http://www.example.com/$1 [R=permanent,QSA,L]