0
我正在使用Apache 2作爲Web應用程序。在某些URL上添加SSL可選
我想強制大多數URL的SSL。例如如果我去http://example.com/foo
我會被重定向到https://example.com/foo
。
這是很容易使用:
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
RewriteEngine on
RedirectMatch ^(/.*)$ https://example.com$1
</VirtualHost>
不過,我想SSL是可選的具有此模式的任何網址:
example.com/api/*
其原因是是,我的移動應用已經生活並使用網站的http版本,我不想打破它。
我該怎麼做?
的重寫規則,我有以下代碼:'的RewriteCond%{REQUEST_URI} ^/API/ 重寫規則^(/.*)$的https://%{SERVER_NAME} $ 1 [ R,L]',但是當我訪問'http:// example.com/api/offer/feed'時,它會重定向到'http:// example.com/index.php'。它爲什麼這樣做? –
無關的規則? – covener
在[默認的Laravel htaccess文件](https://github.com/laravel/laravel/blob/5.1/public/.htaccess)中找到唯一的其他規則。我很困惑如何解決這個問題,因爲我急需解決這個問題! –