-1

[Advised to post here from StackExchange]

I have a site to work on, because of the way the URLs are built the application seems to have been created on the assumption that it will be at the server root (only app).

On my dev server I have other projects and up to now a simple symlink has been working for me, but that's not the case now because this new app wants to sit at the route and process all URLs arriving on :80.

Hopefully this snippet from httpd.conf will help explain what I'm trying to acheive:

# default for any not matched elsewhere
<VirtualHost *:80>
  ServerName localhost
  DocumentRoot /var/www/html/newproject
</VirtualHost>
# now try to pick out specific URLs
<VirtualHost localhost/webdev>
  DocumentRoot /var/www/html/existingProject
  ServerName localhost/project
</VirtualHost>

Also need to be able to get same affect from wherever I'm accessing the httpd instance from. Hope that makes sense.

DaFoot
  • 101
  • 4

2 Answers2

3

You don't need to use VirtualHosts (in fact, I don't think it will work in the format you have), you just need a simple Alias (from mod_alias).

In the existing VirtualHost directive, create an Alias so that /newproject is directed to /somepath/here/newproject, like this,

Alias /newproject/ /where/it/really/lives/

Then any reference the server gets for /newproject/ will actually be secretly and quietly translated to /where/it/really/lives/.

EightBitTony
  • 9,311
  • 1
  • 34
  • 46
1

If you want to use /webdev as subfolder for another app, just add "Alias /webdev /var/www/html/existingProject" to the first virtualhost and delete the second one.

# default for any not matched elsewhere
<VirtualHost *:80>
  ServerName localhost
  DocumentRoot /var/www/html/newproject
  Alias /webdev /var/www/html/existingProject
</VirtualHost>

And browse for http://localhost/ and http://localhost/webdev/

If you need to add different domain, then:

NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1:80>
  ServerName test.local
  DocumentRoot /var/www/html/existingProject
</VirtualHost>

And to the /etc/hosts you add:

127.0.0.1 test.local

And you browse http://test.local/ and http://localhost/
Andrew Smith
  • 1,143
  • 13
  • 23