Url Rewriting - some advice/help please!

  • Thread starter Thread starter chanko
  • Start date Start date
C

chanko

hi all!

ok i'll try and keep this clean and simple

i have a web app where users can log in and manage a mini site (ie
galleries, files, news....)

and i have a web app which is the site where all that info they can
manage is displayed to the public

the way i'm handling it right now, is that for each user, i make a
copy of said public web app, and change the site_id value within the
web.config so that when you enter their url, the app knows what info
to get from the database

lately, i've been getting requests from my employer to find a way so
as to not have to copy the application for each one of our clients,
and try to see if we can implement url rewriting, where if you pass a
url

www.anyurl.com

the application can map that specific url to a site_id and load the
pertinent information

that way we only have one copy of our web application (in case we make
changes and rolling out those changes isn't such a hassle); instead of
N folders with the same web application, depending on the number of
clients we have


i hope i made myself clear
if anybody can please help me out here, to at least be directed in the
correct way to handle this situation

much appreciated

-cesar
 
It's a bit confusing, because it "sounds" like you really want to use
something like host headers (e.g., clientname.yourdomain.com).

You certainly should *not* have to "copy" an entire site just to suit each
individual client.

Provided you've got a way to tell which client is requesting a page
(authentication)
then you can use this in combination with UrlRewriting to ensure that the
visitor gets to see what is intended for them to see.
Peter
 
hi all!

ok i'll try and keep this clean and simple

i have a web app where users can log in and manage a mini site (ie
galleries, files, news....)

and i have a web app which is the site where all that info they can
manage is displayed to the public

the way i'm handling it right now, is that for each user, i make a
copy of said public web app, and change the site_id value within the
web.config so that when you enter their url, the app knows what info
to get from the database

lately, i've been getting requests from my employer to find a way so
as to not have to copy the application for each one of our clients,
and try to see if we can implement url rewriting, where if you pass a
url

www.anyurl.com

the application can map that specific url to a site_id and load the
pertinent information

that way we only have one copy of our web application (in case we make
changes and rolling out those changes isn't such a hassle); instead of
N folders with the same web application, depending on the number of
clients we have

i hope i made myself clear
if anybody can please help me out here, to at least be directed in the
correct way to handle this situation

much appreciated

-cesar

Using the Request.ServerVariables["HTTP_HOST"] you can get the name of
server. Pont all client domains to one website and check HTTP_HOST in
the code:

string host = Request.ServerVariables["HTTP_HOST"].ToLower();
int site_id;

if (host == "www.anyurl.com") {
site_id = 1;
}

....
 
It's a bit confusing, because it "sounds" like you really want to use
something like host headers (e.g., clientname.yourdomain.com).

You certainly should *not* have to "copy" an entire site just to suit each
individual client.

Provided you've got a way to tell which client is requesting a page
(authentication)
then you can use this in combination with UrlRewriting to ensure that the
visitor gets to see what is intended for them to see.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net














- Show quoted text -

thanks for replying

i don't think i explained myself entirely

i have 2 applications at hand
- administration and
- public

one is the administration site, where a user can log on with their
credentials. with this i have no problem making a difference between
sites. but each user when logged on, can update info on their
"public" site
which is accessible to the whole world. sort of like google pages?
where i can log on and move everything around, but you can access my
page through my url chanko.googlepages.com

it's kind of like that
but in my case, each user or client normally wishes to user their own
url

www.client1.com
www.client2.net

and so forth

so if i have a web application that can render the site with a site
specific stylesheet and content, i wanted to see if i could just use
one single application and get the info from the url as to which site
you as a nonsuspecting internet navigator are trying to see

still pretty confusing? :S


i see alexey smirnov answered by accessing the
Request.ServerVariables["HTTP_HOST"].ToLower();
which i hadn't heard of, but in this case i imagine i would have to
make changes to code and recompile everytime i wanted to add a new
client/site?

thanks for responding!
i really appreciate it!
 
which i hadn't heard of, but in this case i imagine i would have to
make changes to code and recompile everytime i wanted to add a new
client/site?

You can still use the web.config, e.g.

<SiteSettings>
<site_id>
<domainid>1</domainid>
<domain>www.client1.com</domain>
</site_id>
<site_id>
<domainid>2</domainid>
<domain>www.client2.net</domain>
</site_id>
</SiteSettings>

and get the settings out of it.

You can use a database. In this case you don't need to touch the
web.config
 
You can still use the web.config, e.g.

<SiteSettings>
<site_id>
<domainid>1</domainid>
<domain>www.client1.com</domain>
</site_id>
<site_id>
<domainid>2</domainid>
<domain>www.client2.net</domain>
</site_id>
</SiteSettings>

and get the settings out of it.

You can use a database. In this case you don't need to touch the
web.config

so just on every page request, loop through all client/urls in
database and compare the value with
Request.ServerVariables["HTTP_HOST"]?
 
so just on every page request, loop through all client/urls in
database and compare the value with
Request.ServerVariables["HTTP_HOST"]?

In the database you can query similar to the following:

SELECT site_id FROM clients WHERE http_host='anyurl.com'

Note, the HTTP_HOST returns anyurl.com for http://anyurl.com and
www.anyurl.com for http://www.anyurl.com (if you would have 2 host
headers per site: with www and without www)
 
Back
Top