Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom Page Slug with multiple query strings using htaccess

I'm using the following line in my .htaccess file to create custom page stubs

RewriteRule ^([a-zA-Z0-9-/]+)$ index.php?slug=$1 [QSA]

So basically this turns my-site.com/my-fancy-url into my-site.com/index.php?slug=my-fancy-site

I need to add an additional variable onto the query string like this:

my-site.com/index.php?slug=my-fancy-site&customId=5

So I can use this URL:

my-site.com/my-fancy-url/5

Any ideas how I would alter the Rewrite rule to achieve this?

like image 533
Daelan Avatar asked Mar 11 '12 05:03

Daelan


1 Answers

RewriteRule ^([a-zA-Z0-9-/]+)/([0-9]+)$ index.php?slug=$1&customId=$2 [QSA]
like image 171
Gabriella Gonzalez Avatar answered Oct 10 '22 10:10

Gabriella Gonzalez