Hiding php extension for static files
I have used this rule in categories:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-/]+)$ categories.php?url=$1
RewriteRule ^([a-zA-Z0-9-/]+)/$ categories.php?url=$1
I want to hide php extension already for static files like xxx.php. Im using this rule:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
开发者_如何学Python
This rule not working and xxx.php goes to categories.php page. What rule may I use for static pages? may I use any "folder/(.*)$ $1.php" ?
Should work fine, if you make sure to put the second set of rules first. Remember, the rules are executed in order. So, in the order you have the rules in your post, a request to xxx
will be rewritten as categories.php?url=xxx
before the second rule ever sees the request... so it never triggers.
精彩评论