apache_conf WordPress .htaccess配置文件。允许强制SSL,隐藏wp-config.php,标头ETag,GZIP压缩和过期缓存。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf WordPress .htaccess配置文件。允许强制SSL,隐藏wp-config.php,标头ETag,GZIP压缩和过期缓存。相关的知识,希望对你有一定的参考价值。
## BEGIN Force SSL ##
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
## END Force SSL ##
## BEGIN WordPress ##
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
## END WordPress ##
## BEGIN Hide WordPress Config File ##
<files wp-config.php>
order allow,deny
deny from all
</files>
## END Hide WordPress Config File ##
## START Redirects ##
## Redirect 301 /old-page /new-page
## END Redirects ##
## BEGIN Disable ETags ##
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)(\.gz)?$">
Header set Expires "Sun, 01 Jan 2016 20:00:00 GMT"
Header unset ETag
FileETag None
</FilesMatch>
## END Disable ETags ##
## BEGIN GZIP Compression ##
<IfModule mod_deflate.c>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/json
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/xsd
AddOutputFilterByType DEFLATE text/xsl
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/x-js
AddOutputFilterByType DEFLATE text/richtext
AddOutputFilterByType DEFLATE text/svg+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddType x-font/otf .otf
AddType x-font/ttf .ttf
AddType x-font/eot .eot
AddType x-font/woff .woff
AddType image/x-icon .ico
AddType image/png .png
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
## END GZIP Compression ##
## BEGIN Expires Caching ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 7 days"
</IfModule>
## END Expires Caching ##
以上是关于apache_conf WordPress .htaccess配置文件。允许强制SSL,隐藏wp-config.php,标头ETag,GZIP压缩和过期缓存。的主要内容,如果未能解决你的问题,请参考以下文章
apache_conf WordPress安全
apache_conf Wordpress htaccess
apache_conf Wordpress .htaccess
apache_conf 强化Wordpress网站
apache_conf wordpress-安装
apache_conf 增加WordPress上传限制