Skip to Content.
Sympa Menu

internetworkers - Re: [internetworkers] Apache httpd.conf help

internetworkers AT lists.ibiblio.org

Subject: Internetworkers: http://www.ibiblio.org/internetworkers/

List archive

Chronological Thread  
  • From: Steven Champeon <schampeo AT hesketh.com>
  • To: "Internetworkers: http://www.ibiblio.org/internetworkers/" <internetworkers AT lists.ibiblio.org>
  • Subject: Re: [internetworkers] Apache httpd.conf help
  • Date: Wed, 18 Feb 2004 11:37:44 -0500

on Wed, Feb 18, 2004 at 11:29:33AM -0500, Greg Cox wrote:
> > I want mydomain.org to be the primary domain. If anyone visits the site
> > by
> > typing mydomain.com or mydomain.net I want Apache to force a HTTP 301
> > redirect to mydomain.org.
>
> <VirtualHost *:80>
> ServerAdmin me AT mydomain.org
> DocumentRoot /var/www/tld/mydomain
> ServerName www.mydomain.org
> TransferLog logs/tld/mydomain_access_log
> ErrorLog logs/tld/mydomain_error_log
> </VirtualHost>
>
> <VirtualHost *:80>
> ServerName mydomain.org
> ServerAlias mydomain.net www.mydomain.net mydomain.com www.mydomain.com
> TransferLog logs/tld/mydomain_access_log
> ErrorLog logs/tld/mydomain_error_log
> RewriteEngine on
> RewriteRule ^/$ http://www.mydomain.org [R=301,L]
> RewriteRule ^/(.*) http://www.mydomain.org/$1 [R,L]
> <IfModule mod_userdir.c>
> UserDir disabled
> </IfModule>
> </VirtualHost>

Why use mod_rewrite for a simple redirect? Seems like a bit much.

<VirtualHost *:80>
ServerName mydomain.org
TransferLog logs/tld/mydomain_access_log
ErrorLog logs/tld/mydomain_error_log
RedirectMatch permanent ^/(.*) http://www.mydomain.org/$1
</VirtualHost>

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.2
http://httpd.apache.org/docs/mod/mod_alias.html#redirectmatch

Steve,
who has an official craigslist pocket protector, lovingly machine crafted
in white vinyl.

--
hesketh.com/inc. v: (919) 834-2552 f: (919) 834-2554 w: http://hesketh.com
Book publishing is second only to furniture delivery in slowness. -b. schneier




Archive powered by MHonArc 2.6.24.

Top of Page