htaccess无法正常工作 - 查看图片

时间:2012-11-04 00:27:13

标签: .htaccess

Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L]
RewriteRule ^([^/]+)/$ view_image.php?rand=$1 [L]

有人可以告诉我为什么这不起作用?

1 个答案:

答案 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]