[nycphp-talk] Removing www.
inforequest
1j0lkq002 at sneakemail.com
Thu Feb 8 03:06:27 EST 2007
Greg Rundlett greg.rundlett-at-gmail.com |nyphp dev/internal group use|
wrote:
> On 2/7/07, inforequest <1j0lkq002 at sneakemail.com> 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
Greg I think there's a bit more to it, because most DNS / Hosting setups
place the A record and aliases such that they create distinct copies of
your site (per each alias). Search engines will index www. and non-www
and any additional aliases as different sites, and if there is
duplication will likely drop all but one copy. Due to the way search
engines honor incoming links, you can end up with a site whose existence
in search engines depends on the whim of external factors you can't control.
The rewrite rule above throws a 301 Permanent redirect response code,
which the search engines use to help identify the primary web site that
should be kept in the search index. If you care to maintain a stable
presence in the search engines, you need to be sure you have a single
web site URL.
More information about the talk
mailing list