修改如下配置
http配置
/etc/apache2/sites-available/000-default.conf

<VirtualHost *:80>

    #DocumentRoot /var/www/html

    #RewriteEngine On

    #RewriteCond %{HTTP_HOST} ^(([-_a-zA-Z0-9])+)\.\w+\.\w+$ [NC]
    #RewriteRule ^(.*)$ /%1/$1 [L]

    #ErrorLog ${APACHE_LOG_DIR}/error.log
    #CustomLog ${APACHE_LOG_DIR}/access.log combined

    #ErrorDocument 404 "404 Not Found"

    RewriteEngine on
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^/?(.*)$ https://%{SERVER_NAME}/$1 [L,R]

</VirtualHost>

https配置
/etc/apache2/sites-available/default-ssl.conf

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
            #文档路径
            DocumentRoot /var/www/html
            #域名地址重写匹配
            RewriteEngine On
            RewriteCond %{HTTP_HOST} ^(([-_a-zA-Z0-9])+)\.\w+\.\w+$ [NC]
            RewriteRule ^(.*)$ /%1/$1 [L]
            # 错误页面提示
            ErrorDocument 404 "404 Not Found!!!"

            #日志
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
            # SSL 证书配置
            SSLEngine on
            SSLCertificateFile      /etc/apache2/ssl/fullchain.crt
            SSLCertificateKeyFile /etc/apache2/ssl/private.pem

            <FilesMatch "\.(cgi|shtml|phtml|php)$">
                            SSLOptions +StdEnvVars
            </FilesMatch>
            <Directory /usr/lib/cgi-bin>
                            SSLOptions +StdEnvVars
            </Directory>
    </VirtualHost>
</IfModule>

标签: none

添加新评论



NULL