Apache Server configuration support - Mod_rewrite: Rewrite all subdomains, but not www

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > January 2007 > Mod_rewrite: Rewrite all subdomains, but not www





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Mod_rewrite: Rewrite all subdomains, but not www
w.breuer@gmail.com

2007-01-06, 8:11 pm

For a high-loaded website I want to put some things from what was
previously PHP-coded into the .htaccess file.

This is the scenario:

anybody visiting:
http://domainname.ext/
or http://something.domainame.ext/
should be redirected to
http://www.domainname.ext/directory...whateverhetyped

At this moment i'm using for all subdomains

RewriteCond %{HTTP_HOST} ^([^.]+)\.domainname\.ext
RewriteRule ^(.*) http://www.domainname.ext/directory/%1/$1
[R=permanent,L]

and if someone just types http://domeinname.ext/

RewriteCond %{HTTP_HOST} ^domainname\.ext
RewriteRule ^(.*) http://www.domainname.ext/directory/%1/$1
[R=permanent,L]


Now the problem:

1) Can these 2 be combined?
2) It keeps on redirecting as www. is ofcourse also redirected now...
how to catch that?

Davide Bianchi

2007-01-06, 8:11 pm

On 2007-01-04, w.breuer@gmail.com <w.breuer@gmail.com> wrote:
> For a high-loaded website I want to put some things from what was
> previously PHP-coded into the .htaccess file.
>
> This is the scenario:
>
> anybody visiting:
> http://domainname.ext/
> or http://something.domainame.ext/


This can be done by using the ServerAlias directive and ServerName
to 'catch' both and return always the correct servername.

> should be redirected to
> http://www.domainname.ext/directory...whateverhetyped


For this you only need one rewrite rule.

Davide

--
Yo-yo operating system = WinNT: it goes up..., it goes down..., it goes...
-- From a Slashdot.org post
w.breuer@gmail.com

2007-01-08, 7:26 pm

What would it look like then?

Davide Bianchi schreef:

> On 2007-01-04, w.breuer@gmail.com <w.breuer@gmail.com> wrote:
>
> This can be done by using the ServerAlias directive and ServerName
> to 'catch' both and return always the correct servername.
>
>
> For this you only need one rewrite rule.
>
> Davide
>
> --
> Yo-yo operating system = WinNT: it goes up..., it goes down..., it goes...
> -- From a Slashdot.org post


w.breuer@gmail.com

2007-01-08, 7:26 pm

Note; i can only work in .htaccess.. not in the httpd.conf!

Davide Bianchi schreef:

> On 2007-01-04, w.breuer@gmail.com <w.breuer@gmail.com> wrote:
>
> This can be done by using the ServerAlias directive and ServerName
> to 'catch' both and return always the correct servername.
>
>
> For this you only need one rewrite rule.
>
> Davide
>
> --
> Yo-yo operating system = WinNT: it goes up..., it goes down..., it goes...
> -- From a Slashdot.org post


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com