05.02.10 - Redirect to a secure connection in Apache

Through simple rules for the mod_rewrite of Apache we can redirect file o directory access to a secure connection https

Redirect the request for a file or directory is easy as include the following lines into the web root .htaccess Apache file:
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} ^/file$
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R]
This will redirect every request for the file "file" (for example) with HTTP protocol (any wich the access port different from 443) to another HTTPS secure URL similary to "https://www.domain.com/file".
More news about:  apache
Tags:  mod_rewrite,  https,  redirect

Comments

There are no comments jet. Be the first to comment!

Comment