How to create virtual subdomains on the fly?

This is a discussion on How to create virtual subdomains on the fly? within the Apache Web Server forums, part of the Web Server and Related Forums category; How can I rewrite rules to create virtual subdomains on the fly that are only used to pass variables to ...


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 06-23-2005
Justin Sane
 
Posts: n/a
Default How to create virtual subdomains on the fly?

How can I rewrite rules to create virtual subdomains on the fly that are
only used to pass variables to a PHP file?

For instance people access:

steel.suppliers.com

And the servers executes:

http://suppliers.com/cat.php?id=steel

I don't pretend creating actual subdomains. It would only be a shortcut
for visitors. There is going to be hundreds or thousands of names, and
it's impossible to create subdomains by hand...

Is there a way to do it?
Thanks,

--
Justin.
http://www.opera.com/m2/
  #2 (permalink)  
Old 06-23-2005
HansH
 
Posts: n/a
Default Re: How to create virtual subdomains on the fly?

"Justin Sane" <me@privacy.net> schreef in bericht
news:op.ssssjtnagl9owm@sony...
> How can I rewrite rules to create virtual subdomains on the fly that are
> only used to pass variables to a PHP file?
> For instance people access:
> steel.suppliers.com
> And the servers executes:
> http://suppliers.com/cat.php?id=steel
>

Try using a permanent redirect
RewriteCond %{HTTP_HOST} !^www.suppliers.com$ [NC]
RewriteCond %{HTTP_HOST} (.*).suppliers.com$ [NC]
RewriteRule ^/?$ http://www.suppliers.com/cat.php?id=%1 [L, R=302]
to redirect only the initial request.

or try redirecting any request transparently
RewriteCond %{HTTP_HOST} .*(.*).suppliers.com$ [NC]
RewriteRule ^(.*) /cat.php/$1?id=%1 [L,NE]
having cat.php accept the original request as PATH_INFO

or be blund and have cat.php read HTTP_HOST and do its thing!

Just some untested thoughts ...

HansH

HansH


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:23 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0