How do I set a base URL for my website and get it to include in every page?
Is there a way for me to easily change a variable to be the base url for the website, such as <?php $baseurl = "http://www.website.com/website/"; ?>
, and include this on every page so that all CSS, JavaScript, images and PHP includes follow this $baseurl
?
You can’t make both PHP and client-side assets use the same base URL, unless you use PHP to
echo
a base URL variable or constant to the page.The usual approach is to have a bootstrap file that you include on every page, and define your base URL and other site-wide variables in there.
bootstrap.php:
index.php:
(xampp), the How do I use on the local computer. folder layout,
http://www.resimagaci.com/img/90rvnrf.png
ust.php
alt.php
sabitler.php
index.php
You may want to take a look at the html base tag.
Inside the
<head>
section of your html, putOn top of that, you may want to have a
base.php
with default directories and whatnot that you include into your project.