我有一个www.example.com/page.html页面,上面有一个链接,可以在空白页面上找到www.example.com/folder/link.php?id=123456
由于某个特定原因,当我在同一页面上但使用其他语言(页面将像www.example.com/page_ro.html)时,我无法更改此链接并需要使用重写条件来执行此操作改变相同的链接。
在这种情况下,我想要链接成为www.example.com/folder/link.php?id=78910。
在这种情况下我该怎么做?我试过这个没有成功:
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_REFERER} .
RewriteCond %{HTTP_REFERER} ^http://www\.example\.com/page_ro.html [NC]
RewriteCond %(REQUEST_URI) folder/link\.php?id=123456$ [NC]
RewriteRule ^(.*) http://www.example.com/link.php?id=78910 [L]
答案 0 :(得分:0)
您无法使用REQUEST_URI
变量匹配查询字符串。在QUERY_STRING
:
/folder/.htaccess
代替
Options +FollowSymLinks
RewriteEngine On
RewriteBase /folder/
RewriteCond %{HTTP_REFERER} ^http://www\.example\.com/page_ro.html [NC]
RewriteCond %(QUERY_STRING) ^id=123456 [NC]
RewriteRule ^(link\.php)$ $1?id=78910 [NC,L,R=302]