Dynamic systems to by-pass routing to subdomain's home pages

Using a single web hosting account to host multiple sites

Postby Nols Smit » Fri Dec 01, 2006 1:33 am

I did the changes. My .htaccess file:
Code: Select all
RewriteEngine On
Options +FollowSymLinks

RewriteRule ^(.*)report([0-9]+)-site([0-9]+)$                        $1?report_id=$2&site_id=$3                   
RewriteRule ^(.*)report([0-9]+)-country([0-9]+)$                     $1?report_id=$2&country_id=$3                 
RewriteRule ^(.*)report([0-9]+)-country([0-9]+)-province([0-9]+)$    $1?report_id=$2&country_id=$3&province_id=$4   

RewriteCond %{HTTP_HOST} ^(www\.)?(geosites|geoinfo|sageolit|geositesupdate)\.nolsmit\.com$ [NC]
RewriteRule ^(.*)$ http://www.nolsmit.com/%2 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} !^$
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+\.[^\.]+)$ [NC]
RewriteRule !^(geosites|geoinfo|sageolit|geositesupdate).*$ /_%2%{REQUEST_URI} [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} !^$
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule !^(geosites|geoinfo|sageolit|geositesupdate).*$ /_%3/%2%{REQUEST_URI} [QSA,L]

I then tested it with the following results:
Virtual hosts not declared in httpd.conf

http://pat.nolsmit.com/index.html ===> "C:\Program Files\Apache Group\Apache2\htdocs\nolsmit.com\_pat\index.html
Result: HTTP 404 not found
error.log: File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/index.html

http://pat.nolsmit.com ===> "C:\Program Files\Apache Group\Apache2\htdocs\nolsmit.com\_pat\index.html
Result: Displays folder content of "C:\Program Files\Apache Group\Apache2\htdocs"

http://www.nolsmit.com/nolsmit.com/_pat/index.html or http://pat.nolsmit.com/nolsmit.com/_pat/index.html
Result: Correct result but impropper URL

Virtual hosts declared in httpd.conf
http://pat.nolsmit.com or http://pat.nolsmit.com/index.html
Result: Recall C:\Program Files\Apache Group\Apache2\htdocs\nolsmit.com\index.html

Dynamic systems:
www.nolsmit.com/geosites
geosites.nolsmit.com
www.nolsmit.com/geosites?report_id=0&site_id=2
geosites.nolsmit.com/report0-site2
Results:OK
Nols Smit
 
Posts: 9
Joined: Mon Nov 27, 2006 3:37 am
Location: South Africa

Postby richardk » Fri Dec 01, 2006 9:48 am

No <VirtualHost>s.
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?(geosites|geoinfo|sageolit|geositesupdate)\.nolsmit\.com$ [NC]
RewriteRule ^(.*)$ http://www.nolsmit.com/%2/$1 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+\.[^\.]+)$ [NC]
RewriteRule !^(geosites|geoinfo|sageolit|geositesupdate).*$ /%2%{REQUEST_URI} [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule !^(geosites|geoinfo|sageolit|geositesupdate).*$ /%3/_%2%{REQUEST_URI} [QSA,L]

RewriteRule ^(.*)report([0-9]+)-site([0-9]+)$                     $1?report_id=$2&site_id=$3                   [QSA,L]
RewriteRule ^(.*)report([0-9]+)-country([0-9]+)$                  $1?report_id=$2&country_id=$3                [QSA,L]
RewriteRule ^(.*)report([0-9]+)-country([0-9]+)-province([0-9]+)$ $1?report_id=$2&country_id=$3&province_id=$4 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Nols Smit » Mon Dec 04, 2006 4:39 am

It seems OK now where I'm using the hosts file to simulate a DNS server.

I will test it live on a web server and report back.

Thank's a lot.
Nols Smit
 
Posts: 9
Joined: Mon Nov 27, 2006 3:37 am
Location: South Africa

Postby Nols Smit » Mon Dec 04, 2006 1:17 pm

I implemented it on infoveld.com and it's OK.

Thanks’ again
Nols Smit
 
Posts: 9
Joined: Mon Nov 27, 2006 3:37 am
Location: South Africa

Dynamic systems to by-pass routing to subdomain's home pages

Postby Nols Smit » Sun Jan 25, 2009 9:55 am

Hi,

Now 2 years later I move my systems from Apache on Windows to IIS7 on Windows Web Server 2008 and use Helicon's software to do Mod_Rewrite the Apache way.

I changed my folder logic and outlay slightly to adjust for IIS7. The outlay I'm using is on http://www.infoveld.com/folder_outlay.htm

Also each folder per domain may have it's own folder (Intraweb) for dynamic systems and it's own set of folders for sub domains (starting with a underscore).


Summary of my setup:
The root folder of IIS7 is C:\inetpub\wwwroot
In this folder I want to use a main .htaccess file with the only purpose to route requests to the appropriate sub folders. These sub folder names are exactly the same as their corresponding domain names. In these folders I again want to use a .htaccess file. The purpose of this file is firstly to test whether it is a request for a dynamic system and, if true, do the required URL re-writing. If the request is not for a dynamic system, route it to the appropriate sub folder of the sub domain. The names of the sub folder always start with a underscore.

The .htaccess code I'm using under Apache follows:
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?(geosites|geoinfo|sageolit|geositesupdate)\.nolsmit\.com$ [NC]
RewriteRule ^(.*)$ http://www.nolsmit.com/%2/$1 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+\.[^\.]+)$ [NC]
RewriteRule !^(geosites|geoinfo|sageolit|geositesupdate).*$ /%2%{REQUEST_URI} [QSA,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.([^\.]+\.[^\.]+)$ [NC]
RewriteRule !^(geosites|geoinfo|sageolit|geositesupdate).*$ /%3/_%2%{REQUEST_URI} [QSA,L]

RewriteRule ^(.*)report([0-9]+)-site([0-9]+)$ $1?report_id=$2&site_id=$3 [QSA,L]
RewriteRule ^(.*)report([0-9]+)-country([0-9]+)$ $1?report_id=$2&country_id=$3 [QSA,L]
RewriteRule ^(.*)report([0-9]+)-country([0-9]+)-province([0-9]+)$ $1?report_id=$2&country_id=$3&province_id=$4 [QSA,L]


Specific examples of requested and resulting urls I want for IIS7:
My <ServerRoot> is the default: C:\inetpub\wwwroot

Static web pages:
http://www.infoveld.com ==> <ServerRoot>\infoveld.com\index.html
http://pat.infoveld.com ==> <ServerRoot>\infoveld.com\_pat\index.html
http://piet.infoveld.com ==> <ServerRoot>\infoveld.com\_piet\index.html
http://christa.infoveld.com ==> <ServerRoot>\infoveld.com\_christa\index.html

http://www.nolsmit.com ==> <ServerRoot>\nolsmit.com\index.html
http://pat.nolsmit.com ==> <ServerRoot>\nolsmit.com\_pat\index.html
http://piet.nolsmit.com ==> <ServerRoot>\nolsmit.com\_piet\index.html

Dynamic web applications:
My compiled ISAPI dlls are in folder <ServerRoot>\<domain name>\IntraWeb and they are restricted to (for temporary files) a folder <ServerRoot>\<domain name>\IntraWeb\Files and sub-folders below ..\Files

http://sarnap.infoveld.com ==> http://www.infoveld.com/infoveld.com/in ... sarnap.dll
http://geosites.infoveld.com ==> http://www.infoveld.com/infoveld.com/geosites.dll

http://sarnap.nolsmit.com or http://www.nolsmit.com/sarnap ==> http://www.nolsmit.com/nolsmit.com/intraweb/sarnap.dll
http://geosites.nolsmit.com or http://www.nolsmit.com/geosites ==> http://www.nolsmit.com/nolsmit.com/intr ... osites.dll

and using parameters:
... for infoveld.com domain:
http://geosites.infoveld.com/report0/site32 or http://www.infoveld.com/geosites/report0/site32
==> http://www.infoveld.com/infoveld.com/in ... site_id=32

http://geosites.infoveld.com/report0/country2 or http://www.infoveld.com/geosites/report0/country2
==> http://www.infoveld.com/infoveld.com/in ... untry_id=2

http://geosites.infoveld.com/report0/country1/province1 or http://www.infoveld.com/geosites/report ... /province1
==> http://www.infoveld.com/infoveld.com/in ... vince_ID=1

... for nolsmit.com domain:
http://geosites.nolsmit.com/report0/site32 or http://www.nolsmit.com/geosites/report0/site32
==> http://www.nolsmit.com/nolsmit.com/intr ... site_id=32

http://geosites.nolsmit.com/report0/country2 or http://www.nolsmit.com/geosites/report0/country2
==> http://www.nolsmit.com/nolsmit.com/intr ... untry_id=2

http://geosites.nolsmit.com/report0/country1/province1 or http://www.nolsmit.com/geosites/report0 ... /province1
==> http://www.nolsmit.com/nolsmit.com/intr ... vince_ID=1




Regards,

Nols Smit
Nols Smit
 
Posts: 9
Joined: Mon Nov 27, 2006 3:37 am
Location: South Africa

Previous

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 19 guests

cron