madphp
madphp

Reputation: 1764

How rewrite a url slug to a parameter using .htaccess?

I'm looking for the regex url rewriting entries for .htaccess - specifically, I'd like a way to re-write:

/site/this-is-my-slug/

to

/site/?slug=this-is-my-slug

Is this possible?

Upvotes: 2

Views: 1861

Answers (1)

Clive
Clive

Reputation: 36955

Try this:

RewriteRule ^site/(.*)$ site/?slug=$1 [L,QSA]

The QSA flag will copy over any query string from your original URL request so remove it if you don't want this functionality.

Upvotes: 4

Related Questions