Tag Archives: mod_rewrite

Extensibly Redirecting to HTTPS in Apache

I often find myself Googling apache con­fig snip­pets and now that I’m man­ag­ing a server myself, HTTPS is use­ful pretty much every­where. Here is a rewrite that will work in either .htac­cess or a vhost dec­la­ra­tion to redi­rect traf­fic to HTTPS with min­i­mal URL hard-coding.

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteCond %{HTTPS} !=on
	RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]