Categories: Snippets

Current Site URL – Codeigniter

To get host url of current server simply replace

application\config\config.php

$config['base_url'] = '';

with

// Home URL
$sysurl = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$sysurl .= "://" . $_SERVER['HTTP_HOST'];
$sysurl .= str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);

$config['base_url'] = $sysurl;

 

Share

Recent Posts

Clear the browser cache of CSS or JavaScript Using PHP

Other than caching every hour, or every week, you may cache according to file data.…

6 years ago

PHP: fopen error handling

You should first test the existence of a file by file_exists(). [crayon-679fd4fcba726557321534/] or simple solution…

6 years ago

Random String PHP

[crayon-679fd4fcba90f749412695/] Output the random string with the call below: [crayon-679fd4fcba913920905965/]  

6 years ago

PHP function to make slug (URL string)

Note: from WordPress Use it like this: [crayon-679fd4fcbaa07418661728/] Code: [crayon-679fd4fcbaa0a246326006/]  

6 years ago

Include all files with in the folder

[crayon-679fd4fcbab0f609679176/]  

6 years ago

How can I remove 3 characters at the end of a string in php?

[crayon-679fd4fcbaba4760506917/] or [crayon-679fd4fcbaba6238993457/]  

7 years ago