marcparillo
asked on
htaccess chaining rules with variables
Hello experts,
I have a series of .htaccess rules that are working well on my Unix server. I just need to add one extra rule to the chain and I don't know how to do it.
Currently, for every request that comes in, I strip off the last part of the URL and attach it to a PHP page. Like this:
RewriteRule ^(db)\/(\w*)\/?(\d)?$ index.php?page=$1&dbid=$2& autoplay=$ 3
RewriteRule ^(db_search)\/(.*)$ index.php?page=$1&search=$ 2
I also need to add a rule that makes sure there is a www prefix, after all of the other rules have been exercised -- like this:
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L]
I don't understand how to use the [E] or [ENV] flag to attach those variables ($1,$2,$3) to the last RewriteCond, so that if the entire request came in as http://mydomain/db/abc/123 or mydomain.com/db/abc/123, the URL would ultimately be http://www.mydomain/db/abc/123.
Thank you
-marc
I have a series of .htaccess rules that are working well on my Unix server. I just need to add one extra rule to the chain and I don't know how to do it.
Currently, for every request that comes in, I strip off the last part of the URL and attach it to a PHP page. Like this:
RewriteRule ^(db)\/(\w*)\/?(\d)?$ index.php?page=$1&dbid=$2&
RewriteRule ^(db_search)\/(.*)$ index.php?page=$1&search=$
I also need to add a rule that makes sure there is a www prefix, after all of the other rules have been exercised -- like this:
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L]
I don't understand how to use the [E] or [ENV] flag to attach those variables ($1,$2,$3) to the last RewriteCond, so that if the entire request came in as http://mydomain/db/abc/123 or mydomain.com/db/abc/123, the URL would ultimately be http://www.mydomain/db/abc/123.
Thank you
-marc
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.