On 2/7/07, inforequest <[EMAIL PROTECTED]> wrote:
Chris Shiflett shiflett-at-php.net |nyphp dev/internal group use| wrote:

>Joseph Crawford wrote:
>
>
>>Hey guys, what would i need to do in order to make all of the
>>www. be removed from my urls?
>>
>>
>
>>From http://no-www.org/:
>
>RewriteEngine On
>RewriteCond %{HTTP_HOST} ^www\.josephcrawford\.com$ [NC]
>RewriteRule ^(.*)$ http://josephcrawford.com/$1 [R=301,L]
>
>Hope that helps.
>
>Chris
>
>
>
ummm..... be careful when taking code snippets and standards advice from
a site that doesn't validate and is broken in IE7. Especially when it
promotes a back link campaign IMHO.

However, the code looks correct if that is what you want to do. I would
also make sure that the site is not spiderable via https: so that you
don't get traffic bypassing your rewrite rule (or perhaps a port 443
check to the rewrite rule).

-=john andrews

--
-------------------------------------------------------------
Your web server traffic log file is the most important source of web business 
information available. Do you know where your logs are right now? Do you know 
who else has access to your log files? When they were last archived? Where 
those archives are? --John Andrews Competitive Webmaster and SEO Blogging at 
http://www.johnon.com

_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php


If you can edit the apache configuration, here is an extra measure to
ensure that your PHP scripts get the right 'answer' for
_SERVER['HOST_NAME']

create a virtual host container for josephcrawford.com, use the
ServerAlias directive to make the server respond to requests directed
to 'www'.  Tell Apache to use it's canonical ServerName when
constructing self-referential URLs.  Note this will not prevent people
from browsing the www site, so you still need the mod rewrite if you
want to catch those urls AND force them to be democratic (No Dub-ya).

ServerName josephcrawford.com
ServerAlias www.josephcrawford.com foo.josephcrawford.com mr.josephcrawford.com
UseCanonical true

See http://httpd.apache.org/docs/2.2/mod/core.html#serveralias

If you want to ignore / drop the www requests all together, then of
course you don't need the server alias.

On the other hand however if you do care about catching www traffic,
but you want to force it over to the dub-ya-less domain, then the
first answer (setting up an A record in DNS) is key to resolving those
requests to your host.  Good DNS providers / Registrars make this
relatively simple to do.  Combine the A record with a single Virtual
host definition plus ServerAlias directives (as many as you want)

Hope that helps
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com

Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php

Reply via email to