1 |
#LoadModule deflate_module modules/mod_deflate.so |
2 |
#LoadModule headers_module modules/mod_headers.so |
<VirtualHost *:80>
DocumentRoot "E:phpStudyPHPTutorialWWWweb_allaqxc"
ServerName www.xxxx.com
RewriteEngine on
#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
#Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.*).css $1.css.gz [QSA]
# Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.*).js $1.js.gz [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule .css.gz$ - [T=text/css,E=no-gzip:1,E=is_gzip:1]
RewriteRule .js.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1]
Header set Content-Encoding "gzip" env=is_gzip
</VirtualHost>
如果配置https的話只需在httpd-ssl.conf內(nèi)相對應的域名下配置如下:
<VirtualHost *:443>
DocumentRoot "E:phpStudyPHPTutorialWWWweb_allaqxc"
ServerName www.xxxx.com
SSLEngine on
SSLProtocol TLSv1 TLSv1.1 TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "E:phpStudyPHPTutorialApachecertwww.xxxx.com_public.crt"
SSLCertificateKeyFile "E:phpStudyPHPTutorialApachecertwww.xxxx.com.key"
SSLCertificateChainFile "E:phpStudyPHPTutorialApachecertwww.xxxx.com_chain.crt"
RewriteEngine on
#Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.*).css $1.css.gz [QSA]
# Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}.gz -s
RewriteRule ^(.*).js $1.js.gz [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule .css.gz$ - [T=text/css,E=no-gzip:1,E=is_gzip:1]
RewriteRule .js.gz$ - [T=text/javascript,E=no-gzip:1,E=is_gzip:1]
Header set Content-Encoding "gzip" env=is_gzip
<Directory "E:phpStudyPHPTutorialWWWweb_allaqxc">
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
最后一步尤為重要不要忘記!
在你域名指向的項目根目錄下創(chuàng)建一個.htaccess文件里面內(nèi)容如下:注意我這里只配置了css文件和js文件配置,如果還需配置別的后綴類型文件直接加上即可
本文摘自 :https://www.cnblogs.com/