将长网址更改为简短

时间:2015-05-10 17:45:24

标签: .htaccess

如何更改

 www.example.com/index.php?page=2_4_home 

 www.example.com/2/4/home

 www.example.com/2/4/home/

用htaccess?感谢

2 个答案:

答案 0 :(得分:1)

尝试

RewriteEngine on 
RewriteRule ^([0-9]+)/([0-9]+)/([a-zA-Z]+)/?$ /index.php?page=$1_$2_$3 [L]

答案 1 :(得分:0)

尝试:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+(?:index\.php|)\?page=([0-9]+)_([0-9]+)_([^&\ ]+)
RewriteRule ^ /%1/%2/%3/? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/([0-9]+)/([^/]+)/? /index.php?page=$1_$2_$3 [L,QSA]