Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/242.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.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
Php .htaccess将特定域重定向到特定页面_Php_Wordpress_.htaccess_Redirect - Fatal编程技术网

Php .htaccess将特定域重定向到特定页面

Php .htaccess将特定域重定向到特定页面,php,wordpress,.htaccess,redirect,Php,Wordpress,.htaccess,Redirect,我希望来自urlnumbertone.com和urlnumbertwo.com的任何流量重定向到我网站上的几个特定页面 RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://(www.\.)?urlnumberone\.com RewriteRule ^$ /thepath/tomypage/goeshere/ [L] RewriteEngine on RewriteCond %{HTTP_REFERER} ^http://(www.\.)?

我希望来自urlnumbertone.com和urlnumbertwo.com的任何流量重定向到我网站上的几个特定页面

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www.\.)?urlnumberone\.com
RewriteRule ^$ /thepath/tomypage/goeshere/ [L]

RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://(www.\.)?urlnumbertwo\.com
RewriteRule ^$ /thesecond/pathgoeshere/ [L]

现在,这两个URL只是将用户带到我网站的主页,而不是我想要的页面。我做错了什么?如果有关系,该站点是WordPress站点,WordPress规则在这些重定向下,而不是在代码中的重定向之上。

我认为有两个问题。
RewriteCond
行中有一个额外的点,因此括号中的部分当前表示“www(任何字符)(文字点)”,这将阻止匹配需要匹配的域的www版本,除非您尝试匹配像
www6.urlnumberone.com
www3.urlnumberone.com
这样的域

因此,我将替换:

RewriteCond%{HTTP\u REFERER}^HTTP://(www.\)?urlnumberone\.com

与:

RewriteCond%{HTTP\u REFERER}^HTTP://(www\)?urlnumberone\.com

接下来,对于
RewriteRule
行,我将
^$
(替换空字符串)更改为
*
(替换整个路径),并使用302或301重定向。由于WordPress会重写每个不是现有文件或目录的URL,因此很容易错误地进行重定向循环,因此使用301或302应该有助于防止这种情况。因此,我将使用:

RewriteRule.*/thepath/tomypage/goesher/[R=302,L]

也许有一些mod_重写向导有更好的答案,但根据我的经验,这种方法很有效