如何使用的.htaccess更改名称为查询字符串参数? [英] how to change query string parameters with name using .htaccess?
问题描述
我在PHP中传递参数,从一个网页到另一个网页这里是code: -
I am passing parameters from one page to another page in PHP here is the code :-
<a href="index.php?product.php&category_id=<? echo $Getrow['id'];?>" target="_blank">Detail</a>
现在,当我点击详细链接它显示产品的页面,但在本页面CATEGORY_ID是例CATEGORY_ID = 15因此,我不想表现出来而不是这个ID我想用的.htaccess显示类别名称 请帮我
Now when i clicked on detail link it shows product page but at this page category_id is showing for example category_id=15 thus i don't want to show it rather then this id i want show category name using .htaccess please help me
我想它的答案,因为当我们通过查询字符串像example.com/index.php?category_id=15&product_id=13在这个时候有人能像example.com/index.php?category_id=156546565464654&product_id更改= 13546545484我不希望这件事情。
I want its answer because when we pass query string like example.com/index.php?category_id=15&product_id=13 at this time someone can change it like example.com/index.php?category_id=156546565464654&product_id=13546545484 I don't want this thing.
推荐答案
我做同样的事情。
当我创建一个链接,我从文字的使用变量,如&LT创建链接; A HREF =类别-15&gt;点击我&LT; / A&GT;
I do something similar.
When I create a link, I create the link in from of a text using variables, like <a href="category-15">click me</a>
然后在.taccess我这样做
Then in .taccess I do this
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)-([0-9]+)$ search.php?id=$2
,然后链接 http://example.com/category-15
带我到 http://example.com/search? ID = 15
我想,你可以在htaccess的满足您的需求改变的变量,你只需要使用$ 1,$ 2,$ 3等进行更换。 我希望这有助于。
I think, you can change the variables in the htaccess for your needs, you just need to use $1, $2, $3 etc for replacement. I hope this helps.
编辑:我编辑的例子网址,一致性
I edited the example url, for consistency.
这篇关于如何使用的.htaccess更改名称为查询字符串参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!