我可以在htaccess RewriteCond中获得匹配的变量吗?

问题描述:

如何在像这样的规则中访问匹配的变量?我可以在htaccess RewriteCond中获得匹配的变量吗?

RewriteCond %{HTTP_REFERER} ^http://example\.com/dir[0-9]/?(.*)?$ 
RewriteRule ^images/(.*)$ other_dir(MATCHED_STRING)/images/$1 [L] 

我想的网址:http://example.com/dir1 其所有图像重定向到/ other_dir1 /图像/ $ 1

使用从访问的RewriteCond回refernces。因此,在你的例子:

RewriteCond %{HTTP_REFERER} ^http://example\.com/dir[0-9]/?(.*)?$ 
RewriteRule ^images/(.*)$ other_dir%1/images/$1 [L] 

%1将与什么在HTTP引用的是的RewriteCond匹配所取代。

+0

tnx man,that worked – Antagonist