简体   繁体   English

在php中将多个查询字符串转换为seo友好的URL

[英]convert multiple Query String to seo friendly url in php

I have url Like http://somesite.com/packagemenu.php?conname=domestic-tours-packages&consubname=kerala-tours-packages 我有网址喜欢http://somesite.com/packagemenu.php?conname=domestic-tours-packages&consubname=kerala-tours-packages

Now, i want to make it seo friendly with php code or htaccess rewriterule 现在,我想用PHP代码或htaccess rewriterule使其seo友好

my output should be look like this 我的输出应该是这样的

http://somesite.com/domestic-tours-packages/kerala-tours-packages

Simply apply the rewrite rule like this: 只需应用这样的重写规则:

RewriteEngine On
RewriteRule    ^([^/\.]+)/([^/\.]+)$    packagemenu.php?conname=$1&consubname=$2    [NC,L]  

If you want to redirect from querystring to short url, Try the following 如果要从查询字符串重定向到短网址,请尝试以下操作

 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]

shortest way to do it is as above! 最简单的方法是如上所述!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM