Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^([^/]+)/$ view_image.php?rand=$1 [L]
有人可以告诉我为什么这行不通吗?
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^([^/]+)/$ view_image.php?rand=$1 [L]
有人可以告诉我为什么这行不通吗?
将在线回答
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#next is last rule [L],
#all works like following:
#helloworld/ -> helloworld/.php
#helloworld/helloworld -> helloworld/helloworld.php
#image.png -> image.png.php
RewriteRule ^(.*)$ $1.php [L]
#next rule never fires, as 1st rule ooverride it
#and if it would be before previous it will fire only to 1st word:
#image -> skipped
#image/ -> view_image.php?rand=image
#image/image -> skipped
RewriteRule ^([^/]+)/$ view_image.php?rand=$1 [L]