需要帮忙。 rewriterule不使用/?

时间:2022-11-24 00:16:29

My URL is

我的网址是

http://example.com/?aff_id=username 

and I want it like

我想要它

http://example.com/?ap_id=username

I have tried all possible ways but no luck. If I removed ? (question mark) it works but I want ? in my URL. I know it is a regular expression so I tried to escape it but no luck.

我尝试了所有可能的方法,但没有运气。如果我删除了? (问号)它有效,但我想要?在我的网址中。我知道这是一个正则表达式,所以我试图逃避它,但没有运气。

1 个解决方案

#1


You can use the following in your /.htaccess file:

您可以在/.htaccess文件中使用以下内容:

RewriteEngine on
RewriteCond %{QUERY_STRING} aff_id=([\w]+) [NC]
RewriteRule ^$ /?ap_id=%1 [R,L]

If you would like to make the redirect permanent, change R to R=301.

如果您想使重定向成为永久性,请将R更改为R = 301。

#1


You can use the following in your /.htaccess file:

您可以在/.htaccess文件中使用以下内容:

RewriteEngine on
RewriteCond %{QUERY_STRING} aff_id=([\w]+) [NC]
RewriteRule ^$ /?ap_id=%1 [R,L]

If you would like to make the redirect permanent, change R to R=301.

如果您想使重定向成为永久性,请将R更改为R = 301。