Reputation: 1370
I'm having problems getting my URL rewrite to work, I currently have these 3 rules
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
and I want to add a rule where if the user hits http://example.com/metrics/, it sends them to index.php?/sign-in
I've tried doing RewriteRule /metrics/(.*) /index.php?/sign-in [PT]
, but it seems to be conflicting with the .* rule and not sending the user to /index.php?/sign-in at all.
Upvotes: 0
Views: 75
Reputation: 14776
If you have logically conflicting rules, put the more specific before the more general.
For your purpose, something like this should work:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^metrics/?(.*)$ /index.php?/sign-in [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
As an aside, you may want to consider revising your approach.
What if the user is already signed in? Perhaps, your /metrics
page should behave (.htaccess wise) the same as your other pages, and have its code do the equivalent of if( !SignedIn() ) Redirect( "/sign-in" )
in your language of choice.
Upvotes: 1