1

I want to create seo friendly url's for my website. I want to create it from .htaccess file. I have very less knowledge about .htaccess

I have following url http://www.testsite.com/index.php?dispatch=flowers_search.flowers_search_result&city=Pune&type=Carnation

I need to display url as follows, http://www.testsite.com/flowers/Pune/Carnation

Thanks

Burkhard
  • 14,596
  • 22
  • 87
  • 108
absolutek
  • 97
  • 2
  • 4
  • 11

3 Answers3

2

http://www.generateit.net/mod-rewrite/

resulting in:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /index.php?dispatch=flowers_search.flowers_search_result&city=$1&type=$2 [L]
Wurstbro
  • 974
  • 1
  • 9
  • 21
0
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule . /index.php?args=%{REQUEST_URI} [L]
</IfModule>

This will put your query string into a variable that you can use on your page as $_GET['args']. So you call:

http://www.testsite.com/flowers/Pune/Carnation

but you're really displaying the page:

http://www.testsite.com/?args=flowers/Pune/Carnation

You can then take $_GET['args'] and parse it however you want like:

$args = explode('/', $_GET['args']);
array_shift($args); // this take an empty value off of the first item in the array
$dispatch = $args[0];
$city = $args[1];
$type = $args[2];

and so on.

tptcat
  • 3,894
  • 2
  • 32
  • 51
0

Just Try With the following :

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ /index.php?dispatch=$1&city=$2&type=$3 [L]

I think this may help you to resolve your problem.

John Peter
  • 2,870
  • 3
  • 27
  • 46