I am using .htaccess file for rewriting the url's in my php based project. I have written some rules to rewrite the url accordingly. However i was facing problem while writing url for log-in.php with 4 different cases. My current rules are as follows:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#Home Pages rule#
RewriteRule ^home index.php [L]
RewriteRule ^contact-support contact-support.php [L]
#Login Rule#
RewriteRule ^login log-in.php [L]
RewriteRule ^login/([0-9]+)$ log-in.php?temporaryBookingId=$1 [L]
RewriteRule ^login/([0-9]+)/([0-9]+)$ log-in.php?temporaryBookingId=$1&jSessionId=$2 [L]
RewriteRule ^login/([0-9]+)/([0-9]+)/([a-zA-Z]+)$ log-in.php?temporaryBookingId=$1&jSessionId=$2&name=$3 [L]
For the current rules cases are like 1. When there is no parameter in the url then it should open the login page by default. 2. When there are parameters, the login page after filling login credentiials should redirect accordingly. 3. When parameter in the url exceeds the required limit then it must show the page 404 page not found
The bottleneck coming here is that I have written the rule to allow the parametric urls up to 2 only i.e. for temporaryBookingId & jSessionId & name. The url will work like
http://example.com/login/1234/1234/sagar
but when I add more parameters here like
http://example.com/login/1234/1234/sagar/1234/1234
it should show me 404 not found error page
but it is opening the same page again. Here if I comment rule RewriteRule ^login log-in.php [L]
then the above condition works & shows me error page but then if i open simple login page it navigates me back to 404 not found error page. How the rule for log-in.php page to be written in order to satisfy all the conditions?