trying to sort out a way that i can develop a version of my website on my local machine and then upload the files to the live site. The issue is, i want the local site to be completely dependant on itself and there for the css links, the includes etc need to be linking to the local folders.
I use a file called init.php which is in the root of the web folder and this is included into every page. In this init, i include all the stylesheets, jquery and other includes.
If i didnt have any sub folders on my website i would simply use this init.php included on every page and then simply do e.g. css/main.css and include 'includes/header.php' etc.
The problem is that i have folders in my website and still wish to just use the one init.php file that is in the root. However, I need this file to be included and also link to the css files etc that are also in the same place.
The folder structure would be:
root
init.php
databaseconn.php
/css/
main.css
/settings/
user_profile.php
If i include the init.php file in the user_profile.php page, the links to the other files will not work. Currently i am including the init.php onto the user_profile.php pages by denoting a double period (../)
The question is how can i always make the files linked in the init.php file always link to the same correct place no matter what folder i am in, but also whilst not being affected when i move the website files to my live host?
I have tried DIR and document root etc but when used per say as:
<?php define( 'BASE_PATH', __DIR__.'/' ); ?>
<link rel="stylesheet" type="text/css" href="<?php echo BASE_PATH; ?>css/main.css">
This (on MAMP) gives me this URL:
/Applications/MAMP/htdocs/website/css/main.css
Which ofcourse wont work.
How can i do this correctly? I dont want to force the http: part niether incase i get SLL in the future.
Any help would be great!