Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using apache server and PHP, I've just done a cms, and now I would like to provide some demos at different URLs, BUT within the same domain, for example mydomain.com.

Something like this:

http://www.mydomain.com/demo1

http://www.mydomain.com/demo2 ...

If those were the corresponding real paths on my server:

/myserver/cms/demo1
/myserver/cms/demo2

I don't want to change my cms code to achieve this (if possible)

The first solution I thought of was buy a domain for each demo, and use Virtual Hosting to map a demo to a domain. That would do exactly what I want, but that would be too expensive...

With Alias directive,

Alias /demo1/ /myserver/cms/demo1

is almost perfect, but I still got the problem that the $_SERVER['REQUEST_URI'] variable is modified from / to /demo1, which unfortunately makes my cms confuse.

I would need a truly unobstrusive way of doing this, like with virtual hosts.

If you've faced that problem too, I would like to hear how you dealed with it.

share|improve this question

2 Answers 2

I use sub-domains (demo1.example.com, demo2.example.com, etc.) with a wildcard DNS entry (*.example.com always resolves to the same host) so that I don't have to make any DNS changes, I only have to add more virtual hosts to Apache.

Works well.

share|improve this answer
    
Thank you. I'll try that! –  ling Apr 20 '12 at 18:27

Answer to myself::

If you were interested by the topic, here is how I did ( and it worked, thanks to gravyface, ):

<VirtualHost *:80>
    ServerName test.jetdemo
    ServerAlias test.jetdemo
    DocumentRoot "/Volumes/Mac/projets/jetsites/demo/ecommerce/store1/application/www"
</VirtualHost>
<VirtualHost *:80>
    ServerName jetdemo
    ServerAlias *.jetdemo
    DocumentRoot "/Volumes/Mac/projets/jetsites/demo/" 
</VirtualHost>

I've noticed that the order of the virtual hosts' bloc is important: the bloc containing the wildcard ( ServerAlias *.jetdemo ) has to be the last one, otherwise it won't work!, or you'll have to remove the wildcard ( ServerAlias jetdemo ).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.