php - Rewrite htaccess file for more than one variable -
i have following htaccess file:
rewriteengine on rewritecond %{request_filename} !-d rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ $1.php rewriterule ^archive/([^/]+)$ news?url=$1 rewriterule ^cars/([^/]+)$ carbrands?brand=$1
this works fine want add last rule works 1 , 2 variables.
i tried modifying last rule this:
rewriterule ^cars/([^/]+)/([^/]+)$ carbrands?brand=$1&model=$2
so code has work open page car brand should work when try access page of car model of car brand. examples:
example.com/cars/bmw(.php) example.com/cars/bmw/3-series(.php)
my modified rule works for:
example.com/cars/bmw/3-series(.php)
how can make work car brand webpage too?
if don't mind having "model" blank, can try:
rewriterule ^cars/([^/]+)(?:/([^/]+|)$ carbrands?brand=$1&model=$2 [l]
or, you'll need 2 rules:
rewriterule ^cars/([^/]+)/([^/]+)$ carbrands?brand=$1&model=$2 [l] rewriterule ^cars/([^/]+)$ carbrands?brand=$1 [l]
one each number of params.
Comments
Post a Comment