Grow your CSS skills. Land your dream job.

preventing links from going to server root

  • # September 30, 2009 at 10:13 am

    I am currently working on a basic site using PHP includes that I am testing locally using MAMP. I am not using dreamweaver so I don’t have the luxury of auto updating links when I transfer to a server.

    The problem is I work on the site locally and it works fine. But when I upload it to http://www.mydomain.com/_clients/_folder_name_ all of my links break because I am using links such as href="/img/image-name.jpg".

    How would I prevent the link from going to my domains server root and just stay inside the folder. Is this something an .htaccess file would do? If so could someone explain how that works?

    Much appreciated!

    # September 30, 2009 at 12:46 pm

    If you’re using relative links, and the structure is the exact same on live as it is locally, you should be having no problems like that.

    # September 30, 2009 at 2:43 pm

    Hey TheDoc. Thanks for the reply. Unfortunately that is exactly the problem the folder structure is different. Let me add more detail.

    Point A.
    I am a freelancer and create multiple sites so I need a folder on my website to place multiple jobs so for example.

    Point B.
    domain root/_clients/job1
    domain root/_clients/job2
    domain root/_clients/job3

    I send the client the link above to review the design. But the problem arises when I have links like. /img/image.jpg because it travels all the way to the domian root folder. What I need is a way to say hey stop here at job1 and get the img folder.

    Point C:
    and then when the client approves the design I need to take the approved job and put it to their server.

    So point A and point C are the same. But when I load it to my client folder on my site the links break.

    Thank you for helping.

    # September 30, 2009 at 4:21 pm

    That is very strange, it shouldn’t be going all the way to the root folder unless it has "../" in front of it.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".