[thelist] mod_rewrite question

Shannon Hubbell brundlefly at gmail.com
Wed Aug 20 16:53:57 CDT 2008


Hmmm... that isn't having any effect either. I just submitted a support
ticket to the host asking if there's anything here that isn't supported by
them. I ran into that once before with them, although everything seems to
check out with their documentation...

Thanks for the response!
Shannon

On Tue, Aug 19, 2008 at 8:11 PM, Mark Groen <evolt at markgroen.com> wrote:

> On Tuesday 19 August 2008 17:31:18 Shannon Hubbell wrote:
> > ........redirecting mydomain.com to www.mydomain.com. This is
> > what I'm using:
> >
> > RewriteEngine on
> > RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
> > RewriteRule ^(.*)$ http://www.mydomain.com/$1 [L,R=301]
> >
> > That's the way it is right now, although I've tried several variations.
> > This has no effect.
>
> Test the Apache {HTTP_HOST} variable to see if the www. is already there
> and,
> if it's not, redirect to the desired host name:
>
> RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
> RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]
>
> To denote that {HTTP_HOST} is an Apache variable, prepend a % character to
> it.
> The regex begins with the ! character, which will cause the condition to be
> true if it doesn't match the pattern. Also have to escape the dot character
> so that it matches a literal dot and not any character, as is the case with
> the dot metacharacter. Also added the No Case flag to make this operation
> case-insensitive.
>
> The RewriteRule will match zero or one of any character, and will redirect
> to
> http://www.example.com plus the original {REQUEST_URI} value. The R=301,
> or
> redirect, flag will cause Apache to issue a HTTP 301 response, which
> indicates that this is a permanent redirection; the Last flag tells
> mod_rewrite that you've completed this block statement.
>
> I plagiarized this from Sitepoint, more about mod_rewrite:
> http://www.sitepoint.com/article/apache-mod_rewrite-examples
>
> Another good place for real world examples:
> http://httpd.apache.org/docs/1.3/misc/rewriteguide.html
> --
> cheers,
>
>        Mark
> --
> --
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>



More information about the thelist mailing list