1

I'm creating a design for my website before coding it in PHP.

The thing is the path to my images/css/javascript is like this : link="/stylesheets/style.css" so it doesn't work when I open it locally (it reaches to my c:/ harddrive).

If I change it to the relative path to make it work locally I have to change everything back when I want to start coding.

What are you guys method to tackle this issue?

David 天宇 Wong
  • 3,724
  • 4
  • 35
  • 47
  • ../ for each parent document, if it have only 1 lvl above it just ../ otherwise ../../ and so go on, obviously this is just for test – Toping Feb 05 '13 at 10:08
  • Could you hack absolute() such that it returns the correct relative link for testing (assuming MeNoMore's edit to make it appear as a function is correct)? At least then it's only a single change on deploy. – m.brindley Feb 05 '13 at 10:09
  • @Ark : of course, but if I use this everywhere, when I finish developpment I have to modify all those ../ back to / that's my problem – David 天宇 Wong Feb 05 '13 at 10:11
  • @Andy : When I test locally my website is located somewhere there : C:/websites/my_project/design/index.html so when it links to "/css/" it goes directly to c:/css – David 天宇 Wong Feb 05 '13 at 10:12
  • @David天宇Wong you said for test, ../ fits perfectly for it, unless i dont get what you want. – Toping Feb 05 '13 at 10:12
  • @Ark yup, but when I finish testing. I have to change "../" which becomes a bother. – David 天宇 Wong Feb 05 '13 at 10:14
  • @Andy except it's not always in the same folder. Sometimes I do have to reach with ../ (which I don't need when I'm launching my product because it will use root path "/something" – David 天宇 Wong Feb 05 '13 at 10:16
  • "except it's not always in the same folder." well then you have no option other than add a variable in front of it and call from the database, and change there evrytime you need. – Toping Feb 05 '13 at 10:18
  • @Ark alright, I thought there would some kind of sandbox software that would emulate a change of root. Thanks! – David 天宇 Wong Feb 05 '13 at 10:19
  • what if you omit the first / use only "css/a.css" ? On the other hand add the full path and later do a replace all? – Techmonk Feb 05 '13 at 10:47
  • It's annoying to do a replace all because I'm constantly remodying my css/js/html after deploying. Answer was given bellow, it works with XAMPP since it's kind of a sandbox. – David 天宇 Wong Feb 05 '13 at 11:27

1 Answers1

1

You can install xampp and there you can code also in PHP.

Install it from here: http://www.apachefriends.org/en/xampp.html. And you can save directly from your computer then you can test them in localhost.

Idrizi.A
  • 9,819
  • 11
  • 47
  • 88