Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

/html/html/test.html 2

Status
Not open for further replies.

martinprior

Technical User
Jan 5, 2004
5
GB
Hello

I'm a newbie to Apache, and am moving my websites onto my own Redhat/Apache2.0 server.

When I first click on a link, it loads /html/test.html .
Next time I click on the same link, it tries to load /html/html/test.html and fails.

The code is:
<td height=&quot;32&quot; width=&quot;100%&quot;><a href=&quot;html/implementation.html&quot;><font face=&quot;Verdana&quot; size=&quot;1&quot;><b><font size=&quot;4&quot;>?</font>Implementation</b></font></a></td>

What's going on?

Cheers - Martin
 
It's the fact that you're using relative URLs in the href attribute of your anchor tag:

<a href=&quot;html/implementation.html&quot;>

A URL of that form tells the browser, &quot;relative to the place in the site where you are now, go to 'html/implementation.html'&quot;.

Assume that you're browser is pointing to [ignore][/ignore]. Since the browser knows its in the html directory, when a user clicks on the link, the browser attempts to add the path &quot;html/implementation.html&quot; to the existing path of &quot;[ignore][/ignore]&quot;, getting &quot;[ignore][/ignore]&quot;.

However, if your tag reads instead:

<a href=&quot;/html/implementation.html&quot;>

Then the leading slash will tell the browser that the path is relative to the document root of the site. The browser will then go to &quot;[ignore][ignore]&quot;.

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Great news!

Now, before I go and update all the old websites, is there a sneaky Apache config to make everything relative. Or do I need to brush up my mass file replace skills?

I have a feeling I'm better off updating the webpages - as it looks like they're non-standard and any fix would cause me long-term problems.

Could I use egrep (or something) to update all the code in a single directory?

Martin
 
Hmmm...

Tried changing it to a &quot;/html/implementation.html at the beginning of each line, and it still does the same thing.

The pages never did this when they were hosted.

And it does the same thing on whichever browser I use.

Not so sure you're right after all... and the DocumentRoot (in the Virtual Hosts part) points to the directory that contains the html directory...

Any other ideas?

Regards

Martin
 
Sleipner214 is right. First of all, the DocumentRoot is the main html directory. If the calling page is in the same directory as the target page, the link should be <a href = &quot;implimentation.html&quot;> If you use <a href = &quot;/html/implimentation.html&quot;> then you are requesting a page from a directory called html inside another directory called html.
 
Yes - there were two pages - optimization and optimisation - that I was testing it on.

You can guess the rest...

Martin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top