Brad Fletcher
Brad Fletcher

Reputation: 3593

Friendly URLs from Query String

My Url's currently look like this

http://audioflare.io/charts?category=drum-bass

but I want them to look like this

http://audioflare.io/charts/drum-bass/

http://audioflare.io/charts/house/

http://audioflare.io/charts/deep-house/

I know its done within the htaccess file, but how?

Upvotes: 0

Views: 34

Answers (1)

Amit Verma
Amit Verma

Reputation: 41249

In htaccess in the document root :

RewriteEngine on

RewriteRule ^charts/([^./]+)/?$ /charts?category=$1 [L]

This rewrites /charts/foobar to /charts?category=foobar .

Remove charts/ from the rewrite pattern if you are going to place this in /charts/.htaccess .

Upvotes: 2

Related Questions