1 |
#LoadModule deflate_module modules/mod_deflate.so |
2 |
#LoadModule headers_module modules/mod_headers.so |
<VirtualHost *:80>
DocumentRoot "E:\phpStudy\PHPTutorial\WWW\web_all\aqxc"
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内相对应的域名下配置如下:
<VirtualHost *:443>
DocumentRoot "E:\phpStudy\PHPTutorial\WWW\web_all\aqxc"
ServerName www.xxxx.com
SSLEngine on
SSLProtocol TLSv1 TLSv1.1 TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5
SSLCertificateFile "E:\phpStudy\PHPTutorial\Apache\cert\www.xxxx.com_public.crt"
SSLCertificateKeyFile "E:\phpStudy\PHPTutorial\Apache\cert\www.xxxx.com.key"
SSLCertificateChainFile "E:\phpStudy\PHPTutorial\Apache\cert\www.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:\phpStudy\PHPTutorial\WWW\web_all\aqxc">
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
最后一步尤为重要不要忘记!
在你域名指向的项目根目录下创建一个.htaccess文件里面内容如下:注意我这里只配置了css文件和js文件配置,如果还需配置别的后缀类型文件直接加上即可