Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^([^/]+)/$ view_image.php?rand=$1 [L]
有人可以告诉我为什么这不起作用?
答案 0 :(得分:0)
将回答内联
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]