htaccess的新功能......所有文件都存在,尽管有404.在这一个文件夹中有50个以上的图像,但是3个图像在最后添加了斜杠。
不工作:
http://shawnrieger.dev/img/photography/small/20100402153906_s.jpg/ http://shawnrieger.dev/img/photography/small/20140404123054_s.jpg/ http://shawnrieger.dev/img/photography/small/20130330110114_s.jpg/
工作的一个例子:
http://shawnrieger.dev/img/photography/small/20160913190428_s.jpg http://shawnrieger.dev/img/photography/small/20120613091849_s.jpg http://shawnrieger.dev/img/photography/small/20120713102800_s.jpg
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^privacy-policy/$ /parts/pages/privacy-policy.php
RewriteRule ^project/([^/]+)/$ /parts/pages/project.php?id=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
</IfModule>
答案 0 :(得分:1)
您必须避免为真实文件添加尾部斜杠,并重新排序规则。
有这样的话:
<IfModule mod_headers.c>
# WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
# WEEK
<FilesMatch "\.(js|css|swf)$">
Header set Cache-Control "max-age=2592000"
</FilesMatch>
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteRule ^privacy-policy/$ /parts/pages/privacy-policy.php [L,NC]
RewriteRule ^project/([^/]+)/$ /parts/pages/project.php?id=$1 [L,NC,QSA]
在测试此更改之前,请先清除浏览器缓存。