[英]convert multiple Query String to seo friendly url in php
我有網址喜歡http://somesite.com/packagemenu.php?conname=domestic-tours-packages&consubname=kerala-tours-packages
現在,我想用PHP代碼或htaccess rewriterule使其seo友好
我的輸出應該是這樣的
http://somesite.com/domestic-tours-packages/kerala-tours-packages
只需應用這樣的重寫規則:
RewriteEngine On
RewriteRule ^([^/\.]+)/([^/\.]+)$ packagemenu.php?conname=$1&consubname=$2 [NC,L]
如果要從查詢字符串重定向到短網址,請嘗試以下操作
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]
最簡單的方法是如上所述!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.