Anay Pareek Anay Pareek - 5 months ago 12
PHP Question

File don't get attached when I use absolute path in HTML CSS

I was using PHP

include
function to include the header and footer but now I want to change location of my files so I created a folder named admin panel and created a PHP file in it. Now I want to connect my
header.php
file using
include
but all the path in header file are give in reference so I want to change it to absolute path but when I change it then it doesn't work.

The reference file path is given like this:

<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="all">


Now when I change it to absolute then it dont work

<link href="/home/username/public_html/css/bootstrap.css" rel="stylesheet" type="text/css" media="all">


I am having GoDaddy hosting so this is the way to add absolute path in GoDaddy they say. This is GoDaddy's answer link:
https://in.godaddy.com/help/what-is-my-absolute-path-16023

If I am doing something wrong then please tell me thanks in advance.

Answer

If you use a forward slash at the beginning of your path, the path will start in your root folder.

Like this:

<link href="/css/bootstrap.css" rel="stylesheet" type="text/css" media="all">

This path should work in any file in any directory.

Comments