Forum Moderators: phranque
I have websites URLs like,
mydomain.com/firstvar/
mydomain.com/firstvar/secondvar/
I am writing .htaccess for it and have written the following two rules
RewriteBase
RewriteRule ^/([^.]+)/$ page1.php?var1=$1 [T=application/x-httpd-php]
RewriteRule ^/([^.]+)/([^.]+)/$ page2.php?var1=$1&var2=$2 [T=application/x-httpd-php]
now, what I am expecting is that when the first URL with one var is called it should call the page1.php by sending one variable and when the second URL is called it must be redirected to the page2.php with two variables.
But the htaccess is not working in the desired mode. No matter which URL i call it always redirect to the page1.php
I was wondering if anyone can help to make the htaccess work in the desired way.
thanks in advance
RewriteRule ^/([^/]+)/$ page1.php?var1=$1 [T=application/x-httpd-php,L]
RewriteRule ^/([^/]+)/([^/]+)/$ page2.php?var1=$1&var2=$2 [T=application/x-httpd-php,L]
Jim
As it is, the regular-expressions pattern-matcher will have to run several matching attempts, trying to find a "best-fit" of the requested URL-path to the pattern, instead of being able to match the request to the pattern (or reject it) in a single left-to-right pass. The number of retries will be equal to the number of characters in the final slash-delimited part of the path, minus one.
Jim