Jump to content

Slightly More Advanced Topic: Dynamic mod_rewrite with PHP ?


nefarious986

Recommended Posts

Hey guys,

 

Lets say that you have a domain: ie. superheros.com.  I have a script that allows you to dynamically create a sub-domain on the fly, ie. superman.superheros.com, or wonderwoman.superheros.com, or even bartman.superheros.com for that matter.

 

Now the script works and you can access everything at superheros.com/subdomain.php?hero=superman

 

But thats not really a 'sub-domain' .. Is there a way to modify apache or mod_rewrite dynamically, so when you create the sub-domain via PHP, it also create a 'superman' sub-domain, you would be able to access it at superman.superheros.com?

 

I m thinking of some solutions, but I think I am way over complicating it, would appreciate some help or a fresh perspective.

 

Thanks, and merry xmas everyone !

If you are the system admin, you can write a PHP script that will add the necessary lines to httpd.conf and/or vhosts, and then restart Apache. If you have CPanel, you can do it through something like snoopy that will pass along a remote hash. Fairly easy...

 

PhREEEk

  • 3 weeks later...

Are you simply trying to remap an unlimited number of virtual subdomains to one physical block of content *OR* also automatically create the content+location etc. all on the fly? Not sure what you're actually trying to achieve here.

 

If you're simply trying to remap ANY subdomain to a current server so, for example, to add homer.superheroes.com, or maggie.superheroes.com or lisa.superheroes.com or matt-groening.superheroes.com etc. etc. etc. - basically <any-name>.superheroes.com

 

- then you can do this easily in any Apache Virtualhost using a wildcard (*) ServerAlias

 

ServerAlias *.superheroes.com

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.