我有一个页面,它是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]
不能使用REQUEST_URI
变量匹配查询字符串。在/folder/.htaccess
:中使用QUERY_STRING
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]