Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Copying dev to live sites - paths break

Options
  • 15-07-2008 3:08pm
    #1
    Registered Users Posts: 1,002 ✭✭✭


    I always thought that absolute paths were better practice than relative paths.
    So developing locally proves annoying when you are forced to have http://localhost/<vDirName>/pages locally, and your live site is http://<url>/pages

    Other than a global change from, e.g. /images/<x.gif> to images/<x.gif>
    is there anyway to avoid broken links, images, etc when you push your site live? :(


Comments

  • Registered Users Posts: 3,594 ✭✭✭forbairt


    What CMS are you using ?


  • Registered Users Posts: 1,002 ✭✭✭MargeS


    I'm doing it in .Net. I realise I can use the default website option under IIS but this is restricted to one site at a time (in XP)


  • Registered Users Posts: 3,594 ✭✭✭forbairt


    You could just set it up as a virtual host and so have it run on a different port ?

    so you'd just go to localhost:8888/pages

    ?

    Normally most CMS software lets you set up paths and so on in them and these get used throughout the site. Define it in one location ... use it everywhere ? Is that an option ? define your base path somewhere and use this variable ?


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    There's no a whole lot you can do I think, seeing as the absolute URLs are already there. Afaik, frontpage has some support for detecting and fixing such links, as does dreamweaver. But I can't vouch for the reliability of either.

    Before going off and doing a global replace from absolute to relative, perhaps give it a bit more thought...

    There are arguments all over the place for relative -v- absolute, but both have their merits.

    A handy thing I've been doing on a (PHP) site recently is extracting a system ID based on the url.

    So for example, I have the live, test and dev environments all running on the same webserver under /live, /test and /dev

    I can use a global variable in PHP which tells the me the URL that was called. Based on this url, the page determines which environment it's in and uses the appropriate database (and also doesn't send emails to users!).

    So for example, the user (in this case me) accesses http://webserver/sitetest/somepage.php. A standard function extracts the word "sitetest" from the url, stores it in a variable called "$system" and from then on it uses the database appropriate to that environment.

    The bonus is then that I can use this variable all over the place. If I want to call absolute urls, I just point to "/$system/somefile.php", and if I want relative I work away as normal.

    It should also be flexible enough so that when the site(s) are moved to a dedicated server, all I'll need to do is change a few base variables (filepaths, DB server, etc) and not have to touch the rest of the codebase.


  • Registered Users Posts: 1,262 ✭✭✭di11on


    What you need to do is set up a local webserver.

    WAMP Server is an all in one package which will install Apache Webserver, MySQL and PHP.

    Then you can set up virtual hosts on Apache which will allow Apache to serve multiple websites identified by their domain name (say www.mysite.com).

    You then edit you hosts file (See "Resolving the DNS issue" in previous link) to override DNS lookup and tell windows that it will find www.mysite.come on your own pc rather than looking for it via DNS.

    Then hey presto... requests to www.mysite.com will be redirected via apache to a local directory on your pc.


  • Advertisement
  • Registered Users Posts: 3,594 ✭✭✭forbairt


    that'd be great except its a .Net site


  • Registered Users Posts: 568 ✭✭✭phil


    OK, not knowing much about .NET, maybe there's some alternative terminology here, but an absolute PATH is /path/to/resource/

    What you're talking about is a full URI.

    Providing resources are on the same domain as yours all the time, there's no need to specify the domain, only the path (hence the name).

    i.e. <a href="/path/to/resource/">

    If you are crossing domains, things get more complicated. Have you multiple domains / sub-domains to link to?

    Btw, I currently deal with this by setting a variable in the global configuration file and everytime I link, I include the variable in the path (templating ftw!). So on the live site, it's just "/" and on my dev site it's "/dev/program/".


Advertisement