You are here: Re: HTML HREFS - confused... « HTML « IT news, forums, messages
Re: HTML HREFS - confused...

Posted by Benjamin Niemann on 04/24/06 00:17

Domestos wrote:

> I've read till I am blue in the face examples and thoughts on proper use
> of the HREF tag.

HREF *attribute*, not tag...

> My prblem is thus.
>
> I develop and test locally and post the development to a website like most
> of us...
>
> my local development 'index.html' exists at...
>
> http://localhost/dev/mywebsite/index.html
>
> however,
>
> My webpage exists at
>
> http://www.mywebsite.com/index.html
>
> How do i use HREF for local links i.e. graphics in the root/GFX folder
> etc..so they work on both my development area and my website without
> changing them everytime I upload them online. I'm really confused.... does
> BASE HREF have a part to play?

a) Use relative URLs, e.g. in document 'foo/bar.html' use
'../gfx/myself.jpeg' to access 'gfx/myself.jpeg'. Not the best solution,
because you have to track the 'directory depth' of the document in order to
get the right number of '../' in the URL. And if you move a document to a
different directory...

b) Configure your local webserver to use virtual hosts, setup a local domain
(if you only work on one computer, editing /etc/hosts or hosts.txt
somewhere below C:\windows should be sufficient), so you can access the
local version via something like 'http://mywebsite-dev/index.html'. Then
you can use URLs relative to the document root, e.g. '/img/myself.jpeg', no
matter how deep you are in the directory structure.

I prefer b)...

> My webpages are developed dynamically through php so I need them to work
> through that too...

This should not make a difference.

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация