【问题标题】:.htaccess Not Caching an Alias Folder's Images.htaccess 不缓存别名文件夹的图像
【发布时间】:2014-06-11 20:24:10
【问题描述】:

因此,由于我将博客托管在与我的网站相同的服务器上,我想我会创建一个别名,这样我就可以提取我的作品集。

Alias /port-images/ /the/real/location/wp-content/uploads/

在我的博客和网站中,我将图片拉入包含以下 .htaccess 代码:

# caching static files
<IfModule mod_headers.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|bmp|js|css|swf|woff|svg|ttf|otf|eot)(\.gz)?$">
Header unset Pragma
Header unset ETag
Header set Cache-Control "max-age=31556000, store, cache"
Header unset Last-Modified
Header set Connection keep-alive
Header add X-PoweredBy ""
</FilesMatch>
</IfModule>
FileETag None
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 seconds"
ExpiresByType text/html M31556000
ExpiresByType image/gif M31556000
ExpiresByType image/jpeg M31556000
ExpiresByType image/png M31556000
ExpiresByType text/css M31556000
ExpiresByType text/javascript M31556000
ExpiresByType application/javascript M31556000
ExpiresByType application/x-javascript M31556000
ExpiresByType text/xml M31556000
ExpiresByType image/svg+xml M31556000
ExpiresByType application/x-font-ttf M31556000
ExpiresByType application/x-font-truetype M31556000
ExpiresByType application/x-font-opentype M31556000
ExpiresByType application/vnd.ms-fontobject M31556000
ExpiresByType application/x-font-woff M31556000  
</IfModule>

# For servers that support output compression, you should pick up a bit of
# speed by un-commenting the following lines.

php_flag zlib.output_compression On
php_value zlib.output_compression_level 9

虽然图像拉入很好,但这些缓存都没有应用于被拉入的图像。我什至将相同的 .htaccess 添加到 /the/real/location/wp-content/uploads/ 并且没有区别。

如何确保这些 .htaccess 设置对位于 /the/real/location/wp-content/uploads/ 中的每个文件/子文件夹都有效?

【问题讨论】:

    标签: php wordpress apache .htaccess mod-alias


    【解决方案1】:

    我在这里查看了 Apache 手册,

    http://httpd.apache.org/docs/2.4/mod/mod_alias.html#alias

    所以它说 Alias 指令只能在服务器配置或虚拟主机中使用,并且不允许在 .htaccess 文件中使用。

    始终尝试查看手册中任何指令描述的第三行,以“上下文:...”开头的行因为它会告诉您可以在哪里使用(以及在哪些地方不能使用)所描述的项目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多