开发者

Hiding php extension for static files

开发者 https://www.devze.com 2023-03-17 04:28 出处:网络
I have used this rule in categories: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消