我的.htaccess文件如下。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^write$ /write.php [L]
RewriteRule ^write/([^/]*)$ /write.php?bid=$1 [L]
RewriteRule (.*)/(.*)/(.*) blog.php?author=$1&title=$2&date=$3
问题是请求将图像文件重定向到blog.php文件。 例如请求 http://domainname.com/images/10005/Brooklyn-Museum.jpg 被重定向到blog.php。如何更正此问题以正确访问现有的静态资源?
答案 0 :(得分:1)
你的规则如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^write/?$ /write.php [L,QSA]
RewriteRule ^write/([^/]+)/?$ /write.php?bid=$1 [L,QSA]
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ /blog.php?author=$1&title=$2&date=$3 [L,QSA]