Hi,
I have a header file which has the html <head>
tag in it. I'm trying to set the <base href="/mysite/">
in this file, but when I include it (such as into my index.php file), it doesn't actually change my base href. Any absolute URLs in index.php (e.g. /css/style.css
) try to load from host/css/style.css
rather than hosthost/mysite/css/style.css
. It seems like it doesn't actually change the base when I'm using an included PHP file. Any ways to solve this issue without having to go back and hardcode every URL?
Thanks
index.php file
<?php
include('_includes/inc_header.php');
inc_header.php file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href="/mysite/html/" />
<link rel="stylesheet" href="/css/style.css" media="screen"/>
The stylesheet doesn't load and view source reveals it is trying to load from host/css/style.css
rather than host/mysite/css/style.css