I'm using Apache as a frontend for a RESTful service I'm building. All access to the service should come in over HTTPS, so I'd like Apache to respond to any HTTP access with a 403 message stating that secure access is required.
How would I configure Apache to do that?
<VirtualHost *:80>
ServerName api.digiumcloud.net
# Stuff to force 403 responses here
</VirtualHost>
I think you may be best by simply redirecting your users to HTTPS. But to do what you want, I think the following should work:
Of course you have to make a 403-message.html file with what you want.
But to redirect to HTTPS:
Add SSLRequireSSL
It isn't HTTPS so it will always result in a Forbidden 403 Error
Redirecting HTTP to HTTPS using something like...
Is the better solution, and does not hardcode the server or URI, preservice the URI as part of the redirection.
However you have to do this in the server configs, and not in ".htaccess".
If you used it in ".htaccess" with authentication, the authentication happens BEFORE the redirection (passwds get sent over HTTP in the clear).
The server configs do not have that problem as the HTTP and HTTPS directives can be placed in separate VHosts.