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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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/ |
|
|||
|
"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 |