Forum Moderators: phranque

Message Too Old, No Replies

"/" does not point to web root

Is there any way to fix with .htaccess file?

         

BeerBoyMcBeer

10:30 pm on Dec 20, 2004 (gmt 0)

10+ Year Member



I've just moved a webpage from my personal server to a commercial one that gives me much more bandwidth. Everything transfered over fine, and a query to my new domain name takes me to the proper place on the server.

However, the way that the server is set up, when I use the forward slash in hyperlinks or image paths, it takes me to the root directory of the server, not the root of my webpage.

I'm new to Apache, but I was under the impression that / should take me to the path set up as my DocumentRoot. Is there any way to make this go to a new place using an .htaccess file, or should I contact my new web administrator?

Thanks for any help you may offer -- please ask if you need any more clarification of my problem.

The Contractor

11:32 pm on Dec 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you are saying yourdomain.com/thisdirectory/index.html takes you back to yourdomain.com/ then yes you have a problem and need to contact your host. If yourdomain.com/thisdirectory/ has an "index" file like index.htm, index.html, or index.php it should call that page or if the default index page is not there should show a list of files that are there in most cases.

Maybe I don't understand what you are stating?

jdMorgan

2:22 am on Dec 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



BeerBoyMcBeer,

Welcome to WebmasterWorld!

> However, the way that the server is set up, when I use the forward slash in hyperlinks or image paths, it takes me to the root directory of the server, not the root of my webpage.

That's a serious server misconfiguration problem, and a security threat as well. The host needs to fix it.

Jim

BeerBoyMcBeer

3:11 am on Dec 21, 2004 (gmt 0)

10+ Year Member



First off, thank you both for replying so quickly to my question.

If you are saying yourdomain.com/thisdirectory/index.html takes you back to yourdomain.com/ then yes you have a problem and need to contact your host.

Luckily, this does NOT happen. Any URLs go to the proper place in the server, just like they're supposed to.

My problem is that if I create a hyperlink like so: <a href="/pagetwo.html">page two</a> then the server looks in the root of the entire server for pagetwo.html, not the root of my web directory.

My folder's two levels down from the server's htdocs folder, so that I'd have to say "/departments/usp/[some file]" to get to my root directory. I also have to say $_SERVER['DOCUMENT_ROOT'].'/departments/usp/[some file]' to access my folder through the PHP DOCUMENT_ROOT superglobal.

My question is whether there is any way to use an .htaccess file to reset the location of my root directory. I've tried using the DocumentRoot directive, but I don't think it's made to be overridden by an .htaccess file. Also, if my DocumentRoot was in the wrong place, wouldn't URLs not go to the right place (as The Contractor said)?

I've never been on a server configured like this before, and I thought that I might have to contact the host. If someone would kindly reaffirm that this is a configuration problem (and not one that can I can fix), then I'll start bugging the admin immediately.

Thanks again! I really appreciate your help.

P.S. -- As an afterthought, do any of you know how one might set up a server like they did (points to the right directory for the index file, but has the root directory somewhere else)? I decided to try and set my server up to emulate the one that I'm having problems with so that I could try and find a possible work-around, but I can't think of any way to set it up like they have it, apart from redirecting each virtual host from the server's htdocs every time. Again, I'm a beginner at this, and I'd appreciate any help you could offer.