2017-06-14 85 views
1

新的htaccess ...儘管404存在所有文件。這一個文件夾中有實際的50多個圖像,但3圖像得到一個斜槓添加到最後。htaccess添加結束斜槓到一些圖像,而不是其他人

不工作:

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> 

回答

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] 

製作到發售者清除瀏覽器緩存在測試此更改之前。

+1

htaccess很混亂。謝謝,這很好。我會嘗試閱讀更多關於這個主題。 – shwnrgr