Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exceptions with mod_rewrite

Status
Not open for further replies.

Mattphp

Programmer
Mar 28, 2005
1
FR
Hi, (and first of all excuse me for my poor english)

I'm getting mad with my httpd.conf, in order to deal with mod_rewrite and a few domain names. (10)
I've read the rewriting guide, and tested all I found, but I can do what I want to.

All my documents are stocked in a location like this:
/home/vhosts/domain.com/

except for one domain name which is with the folowing form:
/home/domain/en/

(I can't change this location, the website has too files and I would have to change to many php includes)

(I precise that Im' running Apache 1.3.)

What I would like is that every subdomains of my domains are redirected in the same directory that www.

So blabla.polo.domain.com, and de.domain.com should be redirected to /home/vhosts/domain.com

So here is what I done (and it does not work)

<VirtualHost 213.186.xx.xx>
ServerName ServerAlias domain.com
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.com$
RewriteRule ^(.+) %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.domain\.com(.*) /home/vhosts/domain.com$2
DocumentRoot /home/vhosts/domain.com
</VirtualHost>

I did that with all <VirtualHosts> elements, except for the one precised before.

I aslo tried to do a _default_:* Virtualhost for that but it does not work.

Please could you tell me how I can deal with this problem, and precise me where I have to put the differents Rewrite* elements. (In <Virtualhost> ? Before ?)

Thank you
Matt
 
Mattphp,

Assuming that I understand what you're trying to do and that you have your DNS records properly set up, I believe that this is possible with the <VirtualHost> directive.

If the URL that you want to direct to /home/domain/en/ is unique, you could set up a _default_:

The special name _default_ can be specified in which case this virtual host will match any IP address that is not explicitly listed in another virtual host. In the absence of any _default_ virtual host the "main" server config, consisting of all those definitions outside any VirtualHost section, is used when no match occurs.


Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top