How to set base URL for all pages of my site?

How to set the base URL for my site and include it in every page?

Is there a way to easily change the variable as the base url for the website, for example <?php $baseurl = "http://www.website.com/website/"; ?>, and include this on every page so that all CSS, JavaScript, images and PHP include this $baseurl?

+5
source share
3 answers

You cannot force both PHP and client resources to use the same base URL unless you use PHP for a echovariable or constant base URL on a page.

, , , URL- .

bootstrap.php:

<?php
    define('BASE_URL', 'http://example.com');

index.php:

<?php
    include('bootstrap.php');
?>
<!DOCTYPE html>
<html>
  <head>
    <!-- // -->
    <link rel="stylesheet" href="<?php echo BASE_URL; ?>/css/styles.css" />
  </head>
  <body>
    <!-- // -->
  </body>
</html>
+13

html .

<head> html

<base href="http://www.website.com/website/">

, base.php -, .

+10

(xampp), . ,

http://www.resimagaci.com/img/90rvnrf.png

ust.php

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
</head>
<body>

alt.php

</body>
</html>

sabitler.php

<?php
#sabitler
define('BASE_URL', 'base-url');
?>

index.php

<?php
include 'kutuphane/sabitler.php';
?>
<?php
$ust= BASE_URL . '/kutuphane/ust.php';
$alt= BASE_URL . '/kutuphane/alt.php';
?>
<?php
include ($ust);
?>
<?php
include ($alt);
?>
-2

All Articles