How to redirect http requests to https on Debian Linux with Apache Web Server?

securing-apache5-590x277

[dfads params=’groups=-1′]

Do the following to redirect http requests to https running on Debian Linux with Apache Web Server.

File : /etc/apache2/ports.conf

[code]
NameVirtualHost *:80
Listen 80
[/code]

File : /etc/apache2/sites-availabe/default

[code]
<VirtualHost *:80>
ServerName www.example.com
Redirect / https://www.example.com/
</VirtualHost>

<VirtualHost *:443>
ServerName www.example.com
# … SSL configuration goes here
</VirtualHost>
[/code]

Restart Apache Webserver

[code]
/etc/init.d/apache2 restart
[/code]

[dfads params=’groups=-1′]

Solution to Url Encoded Slashes (%2F) Problem in Apache

[dfads params=’groups=-1′]

I was working on Drupal 6. I had to troubleshoot a site that has a problem in its link. The ugly URL looks like this: http://rcportblair.ignou.ac.in/admin/build/employee/search/result/none/0/none/%252F1

The last argument in the link i.e. %252F is a forward slash automatically added by the Drupal engine which was creating problem while generating result. There are many ways to handle these urls. One way is listed below:

<VirtualHost *:80>
    AllowEncodedSlashes On
</VirtualHost>

This directive may be set in server config file (e.g. httpd.conf OR /etc/apache2/sites-available/default) and may appear inside <VirtualHost> containers to affect certain websites. Using it in .htaccess files is not allowed.

[dfads params=’groups=-1′]