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 htaccess RewriteCond始终为false_Apache_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

Apache htaccess RewriteCond始终为false

Apache htaccess RewriteCond始终为false,apache,.htaccess,redirect,mod-rewrite,Apache,.htaccess,Redirect,Mod Rewrite,这是一个简单的问题,但它让我抓狂。我遇到了一个重写条件的问题,它的值总是为false。案件的一些事实: 1:我的系统是Apache/2.4.6(CentOS)。 2:我安装了proxy_模块proxy_http_模块和rewrite_模块。 3:我的公共html文件夹位于var/www/html。没有符号链接或别名 好的,交易是我有这个链接: http://mycoolsite.com/fake/ 我只想把它重定向到 http://mycoolsite.com/real/ 这条规则非常有效

这是一个简单的问题,但它让我抓狂。我遇到了一个重写条件的问题,它的值总是为false。案件的一些事实:

1:我的系统是Apache/2.4.6(CentOS)。 2:我安装了proxy_模块proxy_http_模块和rewrite_模块。 3:我的公共html文件夹位于var/www/html。没有符号链接或别名

好的,交易是我有这个链接:

http://mycoolsite.com/fake/
我只想把它重定向到

http://mycoolsite.com/real/ 
这条规则非常有效:

RewriteRule ^fake/(.*)$ http://mycoolsite.com/real/$1 [R=301,L]
将所有流量从一个文件夹发送到另一个文件夹。但是,如果在该规则前面有此重写条件:

RewriteCond ${REQUEST_URI} ^/fake/$
RewriteRule ^fake/(.*)$ http://mycoolsite.com/real/$1 [R=301,L]
然后此url:

http://mycoolsite.com/fake/ 
把我带到假目录,就这样结束了。重写规则被忽略。我用PHP记录了服务器变量,我看得很清楚:“REQUEST_URI'=>”/fake/”。所以url应该正好通过重写规则。那么,为什么我的重写会停止流呢?我知道我在这里遗漏了一些非常简单的东西。下面是htaccess文件的完整列表

Options +FollowSymLinks
RewriteEngine On

RewriteCond ${REQUEST_URI} ^/fake/$
RewriteRule ^fake/(.*)$ http://glowingbluecore.com/real/$1 [R=301,L]

(抢先回答一个问题-此示例只是为了说明我在RewriteCond中遇到的问题。我没有尝试将流量从一个文件夹重定向到另一个文件夹。)

您拼错了变量名。这是
%{REQUEST\u URI}
而不是
${REQUEST\u URI}
,这就是您的条件失败的原因

RewriteCond %{REQUEST_URI} ^/fake/$