how can I rewrite URL to fancy 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/
or
mysite.com/mygetvar1=mygetvar_value1/mygetvar2=mygetvar_value2/
How can I do this? Please help! 开发者_开发技巧Thanks!
Codeigniter can offer you like that. Many other PHP frameworks offer that as well.
Try this.
RewriteRule /([^/]*)/([^/]*)/([^/]*)/([^/]*)/ /login.php?$1=$2&$3=$4 [R=301]
RewriteRule /([^/]*)=([^/]*)/([^/]*)=([^/]*)/ /login.php?$1=$2&$3=$4 [R=301]
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]
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
For your regex , you should use a site like http://www.rubular.com
You can use the .htaccess file or put in directly in the httpd.conf file
精彩评论