<?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>Xavisys&#187; htaccess</title>
	<atom:link href="http://xavisys.com/tag/htaccess/feed/" rel="self" type="application/rss+xml" />
	<link>http://xavisys.com</link>
	<description>WordPress Plugins and Custom WordPress Development</description>
	<lastBuildDate>Wed, 16 Nov 2011 20:45:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<atom:link rel='hub' href='http://xavisys.com/?pushpress=hub'/>
		<item>
		<title>Cell phone safe redirecting with mod_rewrite</title>
		<link>http://xavisys.com/cell-phone-safe-redirecting-with-mod_rewrite/</link>
		<comments>http://xavisys.com/cell-phone-safe-redirecting-with-mod_rewrite/#comments</comments>
		<pubDate>Thu, 26 Jul 2007 23:45:18 +0000</pubDate>
		<dc:creator>Aaron D. Campbell</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://xavisys.com/cell-phone-safe-redirecting-with-mod_rewrite/</guid>
		<description><![CDATA[This is an update to Redirecting all ServerAliases to a preferred domain with mod_rewrite. In that article I solved a problem that I was having where I needed to redirect all ServerAlias options to just one domain, preserving the ssl preference. However, we have a lot of users on cell phones. Some of the simple [...]]]></description>
			<content:encoded><![CDATA[<p>This is an update to <a href="http://xavisys.com/redirecting-all-serveraliases-to-a-preferred-domain-with-mod_rewrite/">Redirecting all ServerAliases to a preferred domain with mod_rewrite</a>.  In that article I solved a problem that I was having where I needed to redirect all ServerAlias options to just one domain, preserving the ssl preference.  However, we have a lot of users on cell phones.  Some of the simple cell phones (like the Motorolla Razr) do NOT like addresses that are missing the www.  A simple url like http://mysite.com?u=user&amp;p=password would not work, because it didn&#8217;t store the session cookie properly.  Adding a www causes the cookies to work, but our ssl certificate is for mysite.com and having the www in that case causes warnings, and I still wanted to redirect our .net and .org TLDs.  I ended up deciding that having the www would be ok as long as the user was NOT trying to use SSL.  Here is how I did it:</p>
<pre class="brush: bash; title: ; notranslate">
&lt;ifmodule&gt;
RewriteEngine On
RewriteCond %{SERVER_PORT}%{HTTP_HOST}  !^(443|80(www\.)?)?mysite\.com [NC]
RewriteCond %{HTTP_HOST}                ^(www\.)?
RewriteCond %{SERVER_PORT}s%1           ^80s(www\.)?|443((s)(www\.))?$
RewriteRule ^(.*)                       http%3://%1mysite.com/$1 [L,R=301]
&lt;/ifmodule&gt;
</pre>
<p>Again, this is in the .htaccess file.  In the end, a user using SSL is <em>always</em> sent to https://mysite.com.  Standard connections are redirected to .com, but their www selection is preserved.<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://xavisys.com/redirecting-all-serveraliases-to-a-preferred-domain-with-mod_rewrite/' title='Redirecting all ServerAliases to a preferred domain with mod_rewrite'>Redirecting all ServerAliases to a preferred domain with mod_rewrite</a></li>
<li><a href='http://xavisys.com/php-function-to-redirect-a-user-with-a-message/' title='PHP function to Redirect a user with a message'>PHP function to Redirect a user with a message</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://xavisys.com/cell-phone-safe-redirecting-with-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Redirecting all ServerAliases to a preferred domain with mod_rewrite</title>
		<link>http://xavisys.com/redirecting-all-serveraliases-to-a-preferred-domain-with-mod_rewrite/</link>
		<comments>http://xavisys.com/redirecting-all-serveraliases-to-a-preferred-domain-with-mod_rewrite/#comments</comments>
		<pubDate>Sat, 07 Jul 2007 01:35:46 +0000</pubDate>
		<dc:creator>Aaron D. Campbell</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[redirect]]></category>

		<guid isPermaLink="false">http://xavisys.com/redirecting-all-serveraliases-to-a-preferred-domain-with-mod_rewrite/</guid>
		<description><![CDATA[I had a domain that I owned three TLDs for. I had the .com, the .net, and the .org. These all go to the same site using ServerAlias directives in the apache config. As do the www versions of each. However, I preferred to have them all go to mysite.com with no www. To add [...]]]></description>
			<content:encoded><![CDATA[<p>I had a domain that I owned three TLDs for.  I had the .com, the .net, and the .org.  These all go to the same site using ServerAlias directives in the apache config.  As do the www versions of each.  However, I preferred to have them all go to mysite.com with no www.  To add to the confusion, the site allows (but does not require) SSL, so the user&#8217;s SSL state needed to be preserved during all this rewriting.  Here is what I came up with, and it works great.</p>
<pre class="brush: bash; title: ; notranslate">
&lt;ifmodule&gt;
RewriteEngine On
RewriteCond %{HTTP_HOST}    !^mysite\.com [NC]
RewriteCond %{HTTP_HOST}    !=&quot;&quot;
RewriteCond %{SERVER_PORT}s ^(80s|443(s))$
RewriteRule ^(.*)          http%2://mysite.com/$1 [L,R=301]
&lt;/ifmodule&gt;
</pre>
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://xavisys.com/cell-phone-safe-redirecting-with-mod_rewrite/' title='Cell phone safe redirecting with mod_rewrite'>Cell phone safe redirecting with mod_rewrite</a></li>
<li><a href='http://xavisys.com/php-function-to-redirect-a-user-with-a-message/' title='PHP function to Redirect a user with a message'>PHP function to Redirect a user with a message</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://xavisys.com/redirecting-all-serveraliases-to-a-preferred-domain-with-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

