🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: demon.tech.unix
Article #368

Re: apache & mod_rewrite

#368
From: David Coulson
Date: Tue, 03 Oct 2000 00:00
38 lines
1932 bytes
Ian wrote:

> I want these to be rewritten to one URL - www.examplesite.co.uk
> 
> I think I've achieved this by;
> 
> RewriteCond %{HTTP_HOST}        !www.examplesite.co.uk
> RewriteRule ^.*$        http://%{SERVER_NAME}%{REQUEST_URI} [R]

I'd personally use

RewriteRule (.*)	http://www.examplesite.co.uk/$1 [R,L]

because it'll then also track GET variables.

> (2)
> Now - I wish to have all requests to  www.examplesite.co.uk/ go to my
> normal document root, but www.examplesite.co.uk/any-other-text (where
> 'any-other-text', really is any text at all) redirected to
> www.examplesite.co.uk/redirect.
> 
> Anything I write seems to put a browser in an endless loop, or try to
> access www.examplesite.co.uk/any-other-text.

Heh, not asking much, are we?

RewriteRule /go		http://www.examplesite.co.uk/ [R,]
RewriteRule /redirect	http://www.examplesite.co.uk/ [R,L]
RewriteRule /(.+)	http://www.examplesite.co.uk/redirect [R]

Should work, although I've not tested it. IMHO, you really need to plan
what exactly you are trying to get your site to do, so you don't need
loads of messy rewrites all over the place (mod_rewrite ain't the
quickest thing on earth, y'know).

-- 
David Coulson
technoir@sourceforge.net
Technical Details
Message-ID: <39DA3667.CFD0DB2E@linux.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <39d9d51b.91004647@news.demon.co.uk>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fac57,cf43607257229b22
X-Google-Attributes: gidfac57,public
From: David Coulson <technoir@linux.com>
Subject: Re: apache & mod_rewrite
Date: 2000/10/03
Message-ID: <39DA3667.CFD0DB2E@linux.com>
X-Deja-AN: 677162852
Content-Transfer-Encoding: 7bit
X-NNTP-Posting-Host: demon-gw.technoir.co.uk:194.159.178.177
References: <39d9d51b.91004647@news.demon.co.uk>
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@demon.net
X-Trace: news.demon.co.uk 970602087 nnrp-03:15364 NO-IDENT demon-gw.technoir.co.uk:194.159.178.177
MIME-Version: 1.0
Newsgroups: demon.tech.unix