Roman
Roman

Reputation: 303

How to specify the base_url with SSL installed?

I am using codeigniter to develop an application, everything is fine but I have stacked on how to specify the base_url in config.php, I have installed SSL, I need whatever visitor will type the link the ssl should work like this https://www.zoepoint.com, but what it do now is user should type the whole link as it is for SSL to work, i.e when you type www.zoepoint.com, it comes with no SSL, but also when you type the whole link https://www.zoepoint.com or https://zoepoint.com it works fine but other links on the website does not work.

Currently I have specified base_url = 'https://zoepoint.com/'

Upvotes: 0

Views: 302

Answers (3)

usersn
usersn

Reputation: 127

Try This one

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

Upvotes: 0

DFriend
DFriend

Reputation: 8964

If Apache is your web server then add the code below to your .htaccess file. This code will force any request to use the https protocol.

RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

Upvotes: 1

Lakru roshan
Lakru roshan

Reputation: 11

try this

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

hope this will work for you

Upvotes: 0

Related Questions