2
My server (Apache 2x) is working correctly with SSL certificate but need to prevent that only a single URL accept normal connection (HTTP only).
The current structure is like this (it is messy due to tests already performed)
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
#Redirect permanent / https://domain.com/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTPS} on
#RewriteCond %{SERVER_NAME} =domain.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/complemento/url [NC]
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
Redirect permanent / https://domain.com/
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /home/domain/domain.com.crt
SSLCertificateKeyFile /etc/apache2/ssl/domain.key
SSLCertificateChainFile /home/domain-bundle.crt
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
</IfModule>
This way it doesn’t work. How to proceed?
I’m sorry, but I don’t understand exactly which Urls should be redirected and which should not. Could you please illustrate better?
– Henrique Marti
@Henriquemarti ALL URL’s must be HTTPS. Only ONE must be normal (HTTP).
– Danilo Miguel
@Henriquemarti being more didactic: Any site URL www.example.com should be HTTPS, but the URL (and only it) www.example.com/url-specifics should be normal (HTTPS)
– Danilo Miguel
Try these two answers: resposable 1 answer 2
– Sam