.htaccess可以´;t使用HTTPS访问我的url


.htaccess can´t access with HTTPS to my url

让我解释一下我所做的。

我有这个。htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ api.php?request=$1 [QSA,L]
</IfModule>

当我用HTTP在浏览器上插入url时,我可以访问我的位置。但是如果我使用HTTPS,出现错误,它的错误是:

Not Found
The requested URL /flights/getAirport was not found on this server.
Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.6 with Suhosin-Patch mod_ssl/2.2.9 OpenSSL/0.9.8g Server at 10.0.0.161 Port 443

为什么我可以使用HTTPS访问?

将以下代码添加到.htaccess文件

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]

这将强制所有流量使用HTTPS