'Htaccess debug alternate rules for rewrite rules
I need to parse one or two variables within /a/ "folder". In the past we only needed the one for assoc. Now I need to parse assoc/state separately WHEN someone uses state (it will be only 10% of use cases, so I need to support both use cases).
Example 1: domain.com/a/joe = domain.com/?assoc=joe 2: domain.com/a/joe/ohio = domain.com/?assoc=joe&state=ohio
The following is the first few lines of my htaccess file:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^index\.html?$ / [NC,R,L]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$
RewriteRule ^a/(.*)$ https://%1/?assoc=$1 [L]
RewriteRule ^a/(.*)/(.*)$ https://%1/?assoc=$1&state=$2 [L]
I can get either line to work on its own (for the respective use case):
RewriteRule ^a/(.*)$ https://%1/?assoc=$1 [L]
or
RewriteRule ^a/(.*)/(.*)$ https://%1/?assoc=$1&state=$2 [L]
But with both lines it always parses the first line and I get; domain.com/?assoc=joe/ohio (as one variable only)
Any help on what I am missing here. How do I get htaccess to skip the first option when I have more than one variable?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
