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 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 instead of

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)?

2 Answers 2


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.

  • 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? Sep 7, 2011 at 20:31
  • No, you cannot change the DocumentRoot via .htaccess.
    – EEAA
    Sep 7, 2011 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? Sep 7, 2011 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 7, 2011 at 20:45

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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