我怎么可以重写URL看中网址是什么? [英] how can I rewrite URL to fancy url?
问题描述
在我的用户登录时,我想这是重写发送到URL像这样得到的变量:
when my user logs in, I want the get variables that were sent rewrote onto the URL like so:
http://mysite.com/mygetvar1/mygetvar_value1/mygetvar2/mygetvar_value2/
或
mysite.com/mygetvar1=mygetvar_value1/mygetvar2=mygetvar_value2 /
mysite.com/mygetvar1=mygetvar_value1/mygetvar2=mygetvar_value2/
我怎样才能做到这一点? 请帮忙!谢谢!
How can I do this? Please help! Thanks!
推荐答案
首先,你需要mod_rewrite的模块使能。
First you need the mod_rewrite module enable.
后,把它放进你的配置文件:
After, put this in your config file :
RewriteEngine on
RewriteRule ^ads/(rims|tires|combo)/([0-9]+)/(.+).html /ad.php?noAds=$2 [L,QSA]
这是一个例子。 你的URL看起来象: http://www.yourwebsite.com/ads/rims /331/title.html 但你会调用网址:HTTP // www.yourwebsite.com / ad.php noAds = 331
This is a example. Your url will look like : http://www.yourwebsite.com/ads/rims/331/title.html but you will call the url : http//www.yourwebsite.com/ad.php?noAds=331
有关您正则表达式,你应该使用这样的网站 http://www.rubular.com
For your regex , you should use a site like http://www.rubular.com
您可以使用.htaccess文件或将直接在httpd.conf文件中的
You can use the .htaccess file or put in directly in the httpd.conf file
这篇关于我怎么可以重写URL看中网址是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!