Return-Path: X-Original-To: apmail-httpd-users-archive@www.apache.org Delivered-To: apmail-httpd-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49CA67521 for ; Wed, 17 Aug 2011 16:03:54 +0000 (UTC) Received: (qmail 24578 invoked by uid 500); 17 Aug 2011 16:03:50 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 24539 invoked by uid 500); 17 Aug 2011 16:03:50 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 24531 invoked by uid 99); 17 Aug 2011 16:03:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 16:03:50 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of tevans.uk@googlemail.com designates 209.85.220.173 as permitted sender) Received: from [209.85.220.173] (HELO mail-vx0-f173.google.com) (209.85.220.173) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Aug 2011 16:03:43 +0000 Received: by vxi32 with SMTP id 32so1324031vxi.18 for ; Wed, 17 Aug 2011 09:03:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=znPC8z7J65oXnThnIz9WVRu/Q1h7bw9xp5U9asBEX5I=; b=ufs4mVo01xXrkGO3p2sgMDqc1vkGw/TTowHDExdhR1EMSUBAtG6Pdihh+N6KfB4PQI OIbMpC9SjlzMBxeTcJMp8EaGEA8V06J4HbC7nczUy60RFPfcY4sfkJKOHE5PTvg8KZj2 gsO2VL24j+P845iuhcNk+sUOMKfboXC+7V1YE= MIME-Version: 1.0 Received: by 10.52.90.240 with SMTP id bz16mr1156032vdb.11.1313597003029; Wed, 17 Aug 2011 09:03:23 -0700 (PDT) Received: by 10.52.162.73 with HTTP; Wed, 17 Aug 2011 09:03:22 -0700 (PDT) In-Reply-To: References: Date: Wed, 17 Aug 2011 17:03:22 +0100 Message-ID: From: Tom Evans To: users@httpd.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Subject: Re: [users@httpd] ServerAlias and RewriteRule On Wed, Aug 17, 2011 at 4:56 PM, Richard Taubo wrote: > Thanks! > > So to be 110% clear, since this is kind of important to get right :-) > > 1) So either this =E2=80=93 leave off the / from the end of the rewritten= URL: > =C2=A0 =C2=A0 =C2=A0 =C2=A0RewriteRule ^(.*)$ http://www.example.com$1 [L= ,R=3D301] > > 2) Or this =E2=80=93 not capture the slash from the original URL: > =C2=A0 =C2=A0 =C2=A0 =C2=A0RewriteRule ^/(.*)$ http://www.example.com/$1 = [L,R=3D301] > > 3) But not this =E2=80=93 as was the alternative I started out with (the = browsers I have tested > do not seem mind, but the rewrite logs shows that an extra slash is added= ): > =C2=A0 =C2=A0 =C2=A0 =C2=A0RewriteRule ^(.*)$ http://www.example.com/$1 [= L,R=3D301] > >>> >>> Question 2) >>> Is the method I use to alias "example.com" with "www.example.com", >>> a good way to set up a ServerAlias in my httpd.conf file, or are there = better ways? >>> My current method, as mentioned above, is: >>> =C2=A0 =C2=A0ServerName www.example.com >>> =C2=A0 =C2=A0ServerAlias example.com >>> =C2=A0 =C2=A0RewriteEngine On >>> =C2=A0 =C2=A0RewriteCond %{HTTP_HOST} ^example\.com$ [NC] >>> =C2=A0 =C2=A0RewriteRule ^(.*)$ http://www.example.com$1 [L,R=3D301] >>> >> >> It's fine. Some people prefer to have the host name canonicalization >> occur in a separate vhost, as this separates the configuration for the >> 'correct' hostname from the configuration for 'incorrect' hostnames. > > So instead of: > > =C2=A0 .... > =C2=A0 ServerName www.example.com > =C2=A0 ServerAlias example.com > =C2=A0 RewriteEngine On > =C2=A0 RewriteCond %{HTTP_HOST} ^example\.com$ [NC] > =C2=A0 RewriteRule ^(.*)$ http://www.example.com$1 [L,R=3D301] > > > They would rather create two VirtualHosts like this instead: > > =C2=A0 .... > =C2=A0 ServerName www.example.com > =C2=A0 .... > > > > =C2=A0 .... > =C2=A0 ServerName example.com > =C2=A0 RewriteEngine On > =C2=A0 RewriteRule ^(.*)$ http://www.example.com$1 [L,R=3D301] > =C2=A0 .... > > > > Appreciate your answers! > > Richard Taubo Yep, precisely. Personally I do option 2 for the first question, and multiple vhosts for the second question (but a single vhost is also perfectly fine). Cheers Tom --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org " from the digest: users-digest-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org