Troubleshooting advice - paths not resolving when viewing site locally

Discussion in 'Web Design and Development' started by Ships, Jan 1, 2013.

  1. Ships, Jan 1, 2013
    Last edited: Jan 1, 2013

    Ships macrumors newbie

    Jan 1, 2013
    Ive been around the block with this problem so many times I'm not even sure where to start! Done a lot of searching, spent days on it really. Perhaps someone may have an idea of how best I should attack the issue.

    I have a functioning live web site that i have helped put together ( www.chrisdonaldson My initial involvement was limited to css (.less) tweaks and adding all content, but the bulk of the backend-development was done by someone else, who I can't get help from anymore.
    Up until the end of September I had been able to make any adjustments, and view the site locally with no problems at all. Now, I need to make some more updates, and something has changed (and I can not work out what).
    For some reason the paths aren't resolving correctly. That goes for css, js & images.
    The site has an index.php file which appears to bring in a head.html and an index.html - but I don't know anything about php.

    The crux of the issue is, that everything was working fine before - ie, I could view the site locally, and all paths resolved correctly, but now when I try and view it, I get plain html without any js or css.

    Now I realise I'm supposed to have apache up and running for php - and so I have turned web sharing on, and also tried to go through all the steps to get php going following a tutorial on Lynda .com. But why would this all have worked before without even me thinking about web sharing....and now it doesn't? Something's not adding up.

    I cannot for the life of me think why the paths (which as far as I can tell are all relative, and should work same whether up live or on my machine) aren't working. I did notice that some of the paths to images were a little sloppy, so, in my testing Ive tweaked those, and hey presto, I can at least get images to display locally. But the paths look correct for the css and the js, and well, I am just stumped.
    Is it possibly a localhost problem with php on my system? Are there ways I can systematically go through some steps that may be at issue here?

    Truly, any advice would much appreciated.

    MAC OS 10.6.8 (I also have another site that works fine locally, but it doesn't use any php.)
  2. AFPoster macrumors 68000

    Jul 14, 2008
    Charlotte, NC
    Before when it worked did you have complete access to the servers files via FTP or through your text editor? This might be why you were able to see your changes right away. This is also the best way to make changes if you don't have an admin panel. Me personal below is what I suggest:

    Because the files are .php you need to setup a personal web server on your computer. I personally use MAMP ( download the regular version. Once installed click on "Preferences" select the Ports tab and change the Apache Port to 80, click save and that's it.

    You need to move your site files to the htdocs folder inside of the MAMP folder. This is where "localhost" is linking to on your browser. So make all changes needed and then copy and paste all files and folders to upload to the server.

    To access the site so that it's viewed with jquery, javascript, css, etc open a browser and type "localhost" and it will display your site. Make changes using any editor you'd like and they will show on the browser as you refresh.

    This might seem like a lot but I learned all this from a 2 min video and it's pretty basic. YouTube has a ton of initial setup videos on their site and trust me this will save you a lot of time!
  3. Ships thread starter macrumors newbie

    Jan 1, 2013
    Sorry for the late reply, and thankyou for your response! You pretty much nailed it, AFPoster.

    Though it didn't work straight away after setting up MAMP - I basically needed to set up a virtual host, and this did the trick. The tute i followed was at there was no need for terminal, and was fairly easy to follow for a pleb like me.

    Basically I added a virtual-host to the hosts file (Macintosh HD: private:etc:hosts)
    Then uncommented the line under 'Virtual hosts' #Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf in the httpd.conf file.
    And then, rather than editing the Applications:MAMP:con:apache:httpd.conf file, (as indicated by steps 6 onwards in this tute), I made these additions:

    <VirtualHost *:80> ** DocumentRoot "/Applications/MAMP/htdocs" ** ServerName localhost </VirtualHost>
    <VirtualHost *:80> ** DocumentRoot "/Users/username/Sites/mysitename" ** ServerName mysitename </VirtualHost>
    to the /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf file.

    Anyway, basically now all paths resolve correctly, and I can set up new web roots for new jobs.
  4. AFPoster macrumors 68000

    Jul 14, 2008
    Charlotte, NC
    Glad to hear it and I apologize for the lack of detail on my end. One thing to keep in mind is that if you have a form script it will not work during testing, at least for me it does not, but on my server it does, just as an fyi.
  5. Ships thread starter macrumors newbie

    Jan 1, 2013

Share This Page