skip to Main Content

I have url Like 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

my output should be look like this

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

2

Answers


  1. Simply apply the rewrite rule like this:

    RewriteEngine On
    RewriteRule    ^([^/.]+)/([^/.]+)$    packagemenu.php?conname=$1&consubname=$2    [NC,L]  
    
    Login or Signup to reply.
  2. 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!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search