bstras21
bstras21

Reputation: 1012

Writing clean URLS with 2 parameters that point to index.php

Here is my url:

website.com/index.php?folder=cars&type=ford

and would like it to be website.com/cars/ford and all pages point to index.php that I will grab the params from the url.

I can't seem to get it, here is my .htaccess:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /index.php?folder=$1&app=$2 [L]

This is one example I got from a clean url generator but its not working. Any ideas?

Upvotes: 1

Views: 72

Answers (1)

anubhava
anubhava

Reputation: 785156

You can insert this rule just below RewriteEngine On to redirect old URL to pretty URL:

RewriteEngine On

RewriteCond %{THE_REQUEST} /index\.php\?folder=([^\s&]+)&type=([^\s&]+)\s [NC]
RewriteRule ^ /%1/%2? [R=301,L,NE]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?folder=$1&app=$2 [L,QSA]

Upvotes: 1

Related Questions