<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dee Double Dub &#187; Apache</title>
	<atom:link href="http://www.deedoubledub.com/category/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.deedoubledub.com</link>
	<description>random points of interest</description>
	<lastBuildDate>Fri, 17 Jul 2009 00:30:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Redirect HTTP traffic to HTTPS with Apache</title>
		<link>http://www.deedoubledub.com/2009/03/redirect-http-traffic-to-https-with-apache/</link>
		<comments>http://www.deedoubledub.com/2009/03/redirect-http-traffic-to-https-with-apache/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 23:49:16 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://deedoubledub.phpnet.us/?p=12</guid>
		<description><![CDATA[Occasionally when I am setting up a web server I want all interaction to occur in a secure channel encrypted with SSL.  I like to leave standard HTTP access available so that the standard http:// url still brings you to the proper site, so I redirect HTTP traffic on port 80 to an HTTPS [...]]]></description>
			<content:encoded><![CDATA[<p>Occasionally when I am setting up a web server I want all interaction to occur in a secure channel encrypted with SSL.  I like to leave standard HTTP access available so that the standard http:// url still brings you to the proper site, so I redirect HTTP traffic on port 80 to an HTTPS session on port 443.  Since I only do this once in a while, I always have to go searching for the proper method to do it, so I&#8217;m posting it here for a quick reference and to share it around.</p>
<p>The way to direct HTTP traffic to HTTPS is with the mod_rewrite URL Rewriting Engine module in Apache.  Here is the process that I used earlier today on an Ubuntu 8.04 Server with Apache2.<span id="more-12"></span></p>
<p>First enable the rewrite module using the a2enmod utility:</p>
<p><code>$ sudo a2enmod rewrite</code></p>
<p>Next edit <em>/etc/apache2/sites-available/default</em> to redirect the port 80 virtual host to the port 443 virtual host.<br />
<code><br />
$ sudo vi /etc/apache2/sites-available/default</code></p>
<p><code>&lt;VirtualHost *:80&gt;<br />
RewriteEngine on<br />
RewriteCond  %{SERVER_PORT} ^80$<br />
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L]<br />
. . .<br />
&lt;/VirtualHost&gt;</code></p>
<p><em>RewriteEngine on</em> enables mod_rewrite on this virtual host.  <em>RewriteCond  %{SERVER_PORT} ^80$</em> matches all requests on port 80, then <em>RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L]</em> rewrites the request making it an https:// request.  Now all requests coming in on port 80 (HTTPS) will be redirected to port 443 (HTTPS).</p>
<p>Now save em&gt;/etc/apache2/sites-available/default and reload the Apache configuration to make the rewrite active.</p>
<p><code>$ sudo /etc/init.d/apache2 reload</code></p>
<p>For more information regarding Apache mod_rewrite or more details related to the rewrite rules structure and regular expressions see the <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">documentation</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.deedoubledub.com/2009/03/redirect-http-traffic-to-https-with-apache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
