Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RewriteRule to accept 2 parameters

mydomain.com/MyFolder/parameter-1

I have this htaccess RewriteRule -

RewriteRule ^([a-z0-9\-]+)/?$ index.php?c=$1 [NC,L]

The .htaccess file is inside MyFolder and this only accept a single parameter.

How can do a RewriteRule to accept 2 parameters

mydomain.com/MyFolder/parameter-1/parameter-2

Thanks

like image 885
Paul Sanchez Avatar asked Sep 23 '11 22:09

Paul Sanchez


1 Answers

use this:

RewriteEngine On

# mydomain.com/MyFolder/parameter-1
RewriteRule ^([a-z0-9\-]+)/?$ index.php?c=$1 [NC,L]

# mydomain.com/MyFolder/parameter-1/parameter-2
RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/?$ index.php?c=$1&d=$2 [NC,L]
like image 132
Book Of Zeus Avatar answered Sep 21 '22 23:09

Book Of Zeus