how can I rewrite URL to fancy url?

2019-08-05 05:43发布

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!

3条回答
狗以群分
2楼-- · 2019-08-05 06:11

Codeigniter can offer you like that. Many other PHP frameworks offer that as well.

查看更多
Ridiculous、
3楼-- · 2019-08-05 06:14

Try this.

RewriteRule /([^/]*)/([^/]*)/([^/]*)/([^/]*)/ /login.php?$1=$2&$3=$4 [R=301]
RewriteRule /([^/]*)=([^/]*)/([^/]*)=([^/]*)/ /login.php?$1=$2&$3=$4 [R=301]
查看更多
该账号已被封号
4楼-- · 2019-08-05 06:25

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

查看更多
登录 后发表回答