我有网址赞http://somesite.com/packagemenu.php?conname=domestic-tours-packages&consubname=kerala-tours-packages
现在,我想用php代码或htaccess rewriterule
使它变得友好我的输出应该是这样的
http://somesite.com/domestic-tours-packages/kerala-tours-packages
答案 0 :(得分:2)
只需应用这样的重写规则:
RewriteEngine On
RewriteRule ^([^/\.]+)/([^/\.]+)$ packagemenu.php?conname=$1&consubname=$2 [NC,L]
答案 1 :(得分:1)
如果要从查询字符串重定向到短网址,请尝试以下
RewriteEngine on
RewriteCond %{THE_REQUEST} /packagemenu.php\?conname=([^&]+)&consubname=([^\s]+) [NC]
RewriteRule ^ /%1/%2? [NC,L,R]
#skip the rule if the request is for dir
RewriteCond %{REQUEST_FILENAME} !-d
#skip the rule if the request is for file
RewriteCond %{REQUEST_FILENAME} !-f
#rewrite any other request to "/packagemenu.php?"
RewriteRule ^([^/]+)/([^/]+)/?$ /packagemenu.php?conname=$1&consubname=$2 [NC,L]
最简单的方法就是如上所述!