rewrite subdomeins

Using a single web hosting account to host multiple sites

rewrite subdomeins

Postby stijn » Tue Jan 06, 2009 1:48 am

I have the following problem.

For a site I installed wildcard subdomains, this works fine.

I use some modrewrite rules to redirect those subdomeins.
I used as guideline this article ==>

http://www.organicseo.org/URL_Rewrit...ing_Subdomains

Code: Select all
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^[^\.w{3}]+\.mydomain.eu$
RewriteRule ^(.*) %{HTTP_HOST}$1 [C]
RewriteRule ^([^\.w{3}]+)\.mydomain\.eu(.*) http://www.mydomain.eu/status.php?sub=$1 [R=301,L]


this works fine for every suddomain, expect if the subdomain contains a w.

http://foo.mydomain.eu works fine
http://foow.mydomain.eu doens't work and show the page of http://www.mydomain.eu

Can somebody give my some advice what is wrong ?

thank you !
stijn
 
Posts: 1
Joined: Tue Jan 06, 2009 1:46 am

Postby richardk » Tue Jan 06, 2009 1:19 pm

There is a better version in this FAQ post: Virtual sub domains.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Rewrite sub domains.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^www\.example\.eu$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.eu$ [NC]
RewriteRule ^(.*)$ /status.php?sub=%2 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 19 guests

cron