-4

how to convert this url http://www.example.com/category_listing.php?city=Bangalore&search=Astrology&submit=Go into http://www.example.com/Bangalore/Astrology

easwee
  • 15,757
  • 24
  • 60
  • 83
  • Reposting won't get you an answer. This topic has been covered ad nauseam, and you're not overly burdened with a little googling and research of your own. – mario May 08 '14 at 13:19
  • Googling? He already gave the answer by tagging his "question" with `url-rewriting`. –  May 08 '14 at 13:20

1 Answers1

0

Here is the easiest way to do it.
First, turn on mod_rewrite in .htaccess
Like this:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . category_listing.php

Next, you need to parse the query string in category_listing.php
For example:

$query = explode('/', $_SERVER['REQUEST_URI']);
$city = $query[0]; // 'Bangalore'
$search = $query[1]; // 'Astrology'

Play with array indices, it may be 1 and 2 instead of 0 and 1 depending on your server settings.

That's all it takes!

Oleg Dubas
  • 2,320
  • 1
  • 10
  • 24