Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.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
Regex 301将具有国家域的TLD重定向到另一个域_Regex_Apache_Redirect_Mod Rewrite_Http Status Code 301 - Fatal编程技术网

Regex 301将具有国家域的TLD重定向到另一个域

Regex 301将具有国家域的TLD重定向到另一个域,regex,apache,redirect,mod-rewrite,http-status-code-301,Regex,Apache,Redirect,Mod Rewrite,Http Status Code 301,我正试图将TLD重定向到一个完全不同的域,并开始试图弄清它的底细: 以下是一个源域示例: www.foo.com.au 以及预期目的地重定向: www.bar.com/subpage 现在,我编写了一条规则,在使用curl进行测试时返回200响应: RewriteCond %(HTTP_HOST) ^(?:www\.)?foo\.com\.au$ [NC] RewriteRule (.*) https://www.bar.com/subpage [R=301,L] 如果您能指出什么,我们将

我正试图将TLD重定向到一个完全不同的域,并开始试图弄清它的底细:

以下是一个源域示例:

www.foo.com.au
以及预期目的地重定向:

www.bar.com/subpage
现在,我编写了一条规则,在使用curl进行测试时返回200响应:

RewriteCond %(HTTP_HOST) ^(?:www\.)?foo\.com\.au$ [NC]
RewriteRule (.*) https://www.bar.com/subpage [R=301,L]

如果您能指出什么,我们将不胜感激。谢谢大家!

伙计们,这件事已经解决了

重写规则/条件是正确的,但有一件事。。。。。用大括号代替圆括号来封装HTTP_主机

RewriteCond %{HTTP_HOST} ^(?:www\.)?foo\.com\.au$ [NC]
RewriteRule (.*) https://www.bar.com/subpage [R=301,L]
此代码使重定向按预期工作。细节,细节