How to fix base url in framework


We can set the base url or url in our framework to be automatically without change it wherever you want to place it in htdocs or localhost.

In CodeIgneter we will set it in application/config/config.php

Place this

$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$config['base_url']    = "$root";

//$config[base_url] = "http://localhost/";

In Laravel we will set it in config/app.php

<?php
$root = "http://".$_SERVER['HTTP_HOST'];
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
return [
    'debug' => env('APP_DEBUG', false),
    //'url' => 'http://localhost',
      'url' => $root,
.......


So this is easy to fix all problem in your drive/ PC and your hosting wherever you want.


Monetize your website traffic with US
Monetize your website traffic with Me

1 Response to "How to fix base url in framework"

  1. Hi, for all time i used to check blog posts here early in the dawn, because i enjoy to learn more and more. capital one credit card login

    ReplyDelete

Archive

Populer