linux poison RSS
linux poison Email

Redirect HTTP to HTTPS using mod_rewrite - Apache

mod_rewrite module uses a rule-based rewriting engine (based on a regular-expression parser) to rewrite requested URLs on the fly. It supports an unlimited number of rules and an unlimited number of attached rule conditions for each rule to provide a really flexible and powerful URL manipulation mechanism. The URL manipulations can depend on various tests, for instance server variables, environment variables, HTTP headers, time stamps and even external database lookups in various formats can be used to achieve a really granular URL matching.

mod_rewrite module operates on the full URLs (including the path-info part) both in per-server context (httpd.conf) and per-directory context (.htaccess) and can even generate query-string parts on result. The rewritten result can lead to internal sub-processing, external request redirection or even to an internal proxy throughput

Open up your apache configuration file (httpd.conf) or the virtual host file and insert the following lines to redirect the http request to https
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
you can also insert the same above lines to your .htaccess file to redirect the content of that particular directory to https.




0 comments:

Post a Comment

Related Posts with Thumbnails