.htaccess htaccess替换参数中的字符串

aemubtdh  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(120)

我想替换aaa中以0x开头的ref参数的任何值。
我有这样的链接:domain/test.php?ref=0x1234domain/test.php?ref=0xABC
我想将它们更改为:domain/test.php?ref=aaa .
我想使用php中参数ref的值,但我不想使用初始值0x...,我想使用htaccess修改的值aaa

<?php
echo $_GET['ref']
?>

结果我的代码:aaa

6ovsh4lw

6ovsh4lw1#

我成功的帮助下,从链接后:替换部分查询字符串

RewriteCond %{QUERY_STRING} (.*=)0x(.*) [NC]
RewriteRule ^ %{REQUEST_URI}?%1aaa%2 [L]

for result: aaa1234

or

RewriteCond %{QUERY_STRING} (.*=)0x [NC]
RewriteRule ^ %{REQUEST_URI}?%1aaa%2 [L]

for result: aaa

@Criss Hass谢谢你,你的建议帮我解决了我的问题。

相关问题