php - Is it possible to use <base> tag for specific references and URLs only? -


good day! possible use tag specific references , url's only? encountered problem wherein there error anchor tag , href attribute. example, there module loans, php files of module located @ 1 folder, take of this:

these folders , website:

htdocs - system - members - loans(loan-app.php, loan-sum.php)

if i'm going use base tag, got error whenever place src on tags on code, solution wont include value in base tag in images , use in links. possible?

note: suggested me here need disable opened module avoid concatenation of url , error. realized can't because have link needed enable if open have same location because belong @ same module. unfortunately can cause concatenation of url.

anyway, here previous question in related :

anchor href, if click again anchor link on address doubles or concatenate on existing link. what's best way avoid this?

the base element used relative urls. if use full url a element, img element, link element, etc base element ignored. base element extremely useful when want test local versus live (as should always test locally first). can not choose base element apply situations unless want in extremely convoluted javascript don't recommend.

base element

<base href="https://www.example.com/" /> 

relative urls

<link href="themes/default/style.css" media="screen" rel="stylesheet" type="text/css" />  <img alt="example" src="images/test.png" />  <a href="loans/">loans</a>  <a href="loans/sum/">loan sum</a> 

use index.php in folder loans/sum/[index.php] create clean urls if you're not using such apache rewrites.

effective urls

https://www.example.com/themes/default/style.css

https://www.example.com/images/test.png

https://www.example.com/loans/

https://www.example.com/loans/sums/

most people start out convoluting setups. should only have domain name's root directory (as demonstrated above) , make urls relative.

for base element should use php determine whether site local or live , echo appropriate path; way don't convoluted setup needing 2 separate copies of site.

you want split base element's php code in 2 parts; live site $url2 should only / , since you'll naturally have other projects archived and/or in development localhost you'll change path accordingly.

base element php - part 1

`<?php echo '<base href="'.$url1.$url2.'" />' . "\n";?>` 

base element php - part 2

you'll have little bit of work here should open mind other juicy possibilities down road make life easier plus don't know local directory structures. explore $_server array start putting $url1 string , remember keep simple.

<?php echo '<pre>';print_r($_server);echo '</pre>';?> 

Comments