如何在 ubuntu 16 中为启用 SSL 的站点启用 mod_rewrite

如何在 ubuntu 16 中为启用 SSL 的站点启用 mod_rewrite

mod rewrite 不适用于我的 WordPress 网站

托管服务器是 Google,系统是 Ubuntu 16

我已经添加了“允许覆盖所有

cd /etc/apache2/sites-available$ cat 000-default.conf

该文件的内容如下:

Umar@sla-boot:/etc/apache2/sites-available$ cat 000-default.conf
<VirtualHost *:80>
    ServerName liveonlinetrainingcourses.com
    ServerAlias www.liveonlinetrainingcourses.com
    DocumentRoot /var/www/otc/
    <Directory /var/www/otc>
               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
               #Require all granted
               Order allow,deny
               allow from all
        </Directory>
    Redirect permanent / https://liveonlinetrainingcourses.com/
</VirtualHost>

<VirtualHost *:443>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.

    ServerName liveonlinetrainingcourses.com
        ServerAlias www.liveonlinetrainingcourses.com
        ServerAdmin [email protected]
        DocumentRoot /var/www/otc/

    SSLEngine on
    SSLCertificateFile /home/Umar/liveonlinetrainingcourses.com.crt
    SSLCertificateKeyFile /home/Umar/liveonlinetrainingcourses.com.key
    SSLCACertificateFile /home/Umar/intermediate.crt
    #SSLCertificateChainFile /home/Umar/intermediate.crt

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

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

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

.htaccess 文件是

Umar@sla-boot:/etc/apache2/sites-available$ cd /var/www/otc/
Umar@sla-boot:/var/www/otc$ cat .htaccess
# BEGIN GoDaddy-SSL
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^liveonlinetrainingcourses\.com$ [OR]
RewriteCond %{SERVER_NAME} ^www\.liveonlinetrainingcourses\.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
# END GoDaddy-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>

相关内容