如何使用.htaccess替换查询字符串中的第一个参数名称? [英] How to replace the first parameter name in query string using .htaccess?
本文介绍了如何使用.htaccess替换查询字符串中的第一个参数名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将查询字符串中第一个参数的名称从 p (小写)更改为 P (大写)。它是查询字符串中的第一个参数。
I need to change the name of the first parameter in the query string from p (lower case) to P (upper case). It is the first parameter in the query string.
例如,我需要将网址更改为:
For example, I need to change the url from:
http://www.example.com/shop/?p=product_name
到
http://www.example.com/shop/?P=product_name
框架是wordpress。
The framework is wordpress.
.htaccess代码:
The .htaccess code:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^p=([^&])$
RewriteRule ^securestore/?$ $0?P=%1 [L,NC,R=302]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RedirectMatch 301 ^(.*)/EcoSupp$ $1
</IfModule>
推荐答案
您可以在 DOCUMENT_ROOT / .htaccess
文件中使用以下代码:
You can use this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^p=([^&]+)
RewriteRule ^securestore/?$ $0?P=%1 [L,NC,R=301]
这篇关于如何使用.htaccess替换查询字符串中的第一个参数名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文