我正在使用Apache作为我正在构build的RESTful服务的前端。 所有对服务的访问都应该通过HTTPS来进行,所以我希望Apache能够通过403消息来响应任何HTTP访问,说明需要安全访问。
我将如何configurationApache来做到这一点?
<VirtualHost *:80> ServerName api.digiumcloud.net # Stuff to force 403 responses here </VirtualHost>
我认为,只需将用户redirect到HTTPS即可。 但是要做你想做的事情,我认为以下几点应该是可行的:
RewriteEngine on RewriteRule /403-message.html - [L] RewriteRule ^(.*)$ /403-message.html [L,R=403] ErrorDocument 403 http://api.digiumcloud.net/403-message.html
当然,你必须制作一个403-message.html文件。
但是redirect到HTTPS:
RewriteEngine on RewriteRule ^(.*)$ https://api.digiumcloud.net/$1 [L,R]