Reputation: 115
I have entries in my .htaccess that goes like this:
RewriteRule ^$ dubai/ [R]
RewriteRule ^dubai/$ page/index.php [L]
RewriteRule ^$ pakistan/ [R]
RewriteRule ^pakistan/$ page/index.php [L]
basically I want to make a rule that can handle countries as part of the rewrite, the above code i have is redundant and can cause the file to grow unnecessarily.
Is there a way to automatically redirect the page to page/index.php
if it serves for any countries? I tried putting this line to the last line above:
RewriteRule ^([a-zA-Z\/]*)/$ page/index.php
My problem is it no longer reads the succeeding rules for the other pages to serve. The below lines are samples of the rules just below the last one above:
RewriteRule ^([a-zA-Z\/]*)rent/$ page/index.php?methodcall=rent&for=Rent
RewriteRule ^([a-zA-Z\/]*)landlords/$ page/index.php?methodcall=landlords
What happens is the get vars are no longer read by index.php file, if i remove the last rewriterule the key vars are read properly.
Any suggestions?
Thanks in advance!
Upvotes: 1
Views: 183
Reputation: 49867
Try this:
RewriteEngine on
RewriteRule ^([a-z]+)(\/?)$ page/index.php [NC,QSA,L]
RewriteRule ^([a-z]+)/rent(\/?)$ page/index.php?methodcall=rent&for=Rent [NC,QSA,L]
RewriteRule ^([a-z]+)/landlords(\/?)$ page/index.php?methodcall=landlords [NC,QSA,L]
Upvotes: 4