How can users create subdomains in real time?

I think I found the mistake in my code.

Can you remove the 2nd rule, and put this before the first rule, instead.
RewriteRule ^/load/(.*)$ /member/load.php?f=$1 [L]

If it still fails, higher loglevel would help more, but if you don’t want that,
you should be able to setup another virtual host by copying the same one,
and mess it up for the test.

Hi extras,

I tried that but it blew up all my subdomains. None of them would respond.
I’ve run the loglevel up to 4 and still get no info other than that the /load/etc.
isn’t being rewritten at all, except to look for it in a subdomain.

Maybe it’s time to sacrifice a goat and dance naked in the moonlight? This
is, after all, VOODOO, right? ;D

Kaspar

Strange … I setup vritualhost (with Apache1.3 , though),
and put this in the Virtualhost section and it translated http://any.example.com/load/any.mp3 to /member/load.php?f=any.mp3

And any other than /load/ http://any.example.com/other/a.html to /member/any/other/a.html


RewriteEngine on
RewriteRule ^/load/(.*)$ /member/load.php?f=$1 [L]

RewriteCond %{HTTP_HOST} !^(blog|www)\\.exmaple\\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\\.)?([^\\.]+)\\.exmaple\\.com$ [NC]
RewriteRule !^/*(member|load)/ /member/%2%{REQUEST_URI}

When you say “None of them would respond.”, what’s really happenning?
What is the error you are getting? (in browser or response header, or error log?)

The fact that you want to make changes on the live server
without test environment is making things harder for you.

Have you created another virtual hsot for testing as I suggested?
If so, put Loglevel of 9 and test, again.

Are you sure that there are no other Rewriterules in anywhere?
(in .htaccess of some directory, different part of httpd.conf)

Also, have you thought about using it for subdomain? (if the module is there)
http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html

Hi extras,

What I meant by not responding was that the browser just served up an old
page from its cache. It served the same page regardless of which subdomain I
requested.

sub1.example.com, sub2.example.com, sub3.example.com, etc. all just
served sub0.example.com (presumably from the cache) Ctrl-F5 just gave me a 404.

There are no .htaccess files anywhere. I haven’t set up a test VirtualHost yet but it looks like I’ll have to. I notice you show the RewriteRule without any RewriteCond. All of the subdomains are below /member, so I’m pretty sure I’d need one to capture the subdomain name.

I was counting on the URL already being rewritten to /member/subdomain before
rewriting /load/any.mp3 to /load.php?f=any.mp3

IOW, the actual path on the server was supposed to be rewritten from:

http://sub.example.com/load/any.mp3 to:

/member/sub/load/any.mp3 and then rewritten to:

/member/sub/load.php?f=any.mp3 [if there was a /load/any.mp3 in the URI]

Perhaps it should be:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com [NC]
RewriteRule ^/load/(.*)$ /member/%2/load.php?f=$1 [L]

RewriteCond %{HTTP_HOST} !^(blog|www)\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule !^/*(member|load)/ /member/%2%{REQUEST_URI}

Or have I lost my mind altogether?

Kaspar

Hi extras,

I Got It! Yay! This works:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com [NC]
RewriteRule ^/load/(.*)$ /member/%2/load.php?f=$1 [L]

RewriteCond %{HTTP_HOST} !^(blog|www)\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.example\.com$ [NC]
RewriteRule ^(.*)$ /member/%2$1

Thanks for all your help. Now the subdomains all load their index.html files
and this URI: /load/any.mp3 is rewritten to: /member/sub/load.php?f=any.mp3

MISSION ACCOMPLISHED!

Thanks a ton to everyone who contributed to this thread. And for those who were just reading,
I hope you’ve learned something useful from all this. God bless this forum!

Kaspar

“Never give up. Never surrender!” - Galaxy Quest

Great!

Now, I see what you wanted.
I was thinking you wanted to have one common load.php for all members
instead of having multiple copies. :wink: