4

Someone just set up a directory for me on an Apache server where I will put my PHP application. This directory has an external path of 192.168.1.5/app and points to /home/test/app.

My application references its files by means of URLs like /img/logo.png, rather than ../img/logo.png or something similar. The problem I'm experiencing with this is that these URLs now point to 192.168.1.5/img/logo.png instead of 192.168.1.5/app/img/logo.png.

In IIS, to fix something like this, I would declare the app directory as an application, which would set the root URL to that directory. How do I do something similar in Apache (using this method or something else entirely)?

Maxim Zaslavsky
  • 211
  • 1
  • 4
  • 13

2 Answers2

1

It sounds like you just need to change the DocumentRoot for this application. Since you're accessing it via IP (instead of hostname), I'm guessing that you're using the default apache vhost. If so, change the DocumentRoot in your httpd.conf file to point to /home/test/app, restart apache, and you should be all set.

EEAA
  • 108,414
  • 18
  • 172
  • 242
  • This sounds like what I'm looking for, but I'm not sure whether I can get access to `httpd.conf`. Is there a way to do this through `.htaccess`? – Maxim Zaslavsky Sep 07 '11 at 20:31
  • No, you cannot change the DocumentRoot via `.htaccess`. – EEAA Sep 07 '11 at 20:34
  • Okay, thanks! Sorry, I just have one last question: since this isn't the only application on the server, should I look up `DocumentRoot` or `VirtualDocumentRoot`? In other words, which is more appropriate here? – Maxim Zaslavsky Sep 07 '11 at 20:43
  • If you have more than one application, then you need to change the `DocumentRoot` in whatever `VirtualHost` that is serving this application. – EEAA Sep 07 '11 at 20:45
0

Mod rewrite. There are so many different configurations that I can't post any specific ones here. But you could use dreamweaver to update all links. Are you trying to get /test/app/images/stuff? What directory are the images in? And it is a good thing you are in relative path mode. That saves much time. Try putting the images folder inside test folder.

U4iK_HaZe
  • 631
  • 5
  • 13