This is my base URL:
$config['base_url'] = '//'. $_SERVER['HTTP_HOST'].
str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
This my view:
<form action="<?php echo $this->config->base_url().'index.php/certification/add/'; ?>"
method="post" accept-charset="utf-8" onsubmit ='return false;'>
This is the result:
<form action="//localhost/php/index.php/localhost/php/index.php/certification/add/"
method="post" accept-charset="utf-8" onsubmit="return false;">
Why does this happen? ( Read this if you don't know what protocol-relative URLs are.
You never set the prefix http or https protocol to the base_url. So the form action url will start with // as expected.
It doesn't look like you are getting the base URL correctly. A similar question was already answered here .
$config['base_url']
should not include the file/script path. If you echo it out on it's own, in your case, you should just be getting '//localhost/php/'
What are you trying to do with the additional SCRIPT_NAME stuff?
If I understand correctly you will want to get rid of that part and then use:
<form action="<?php echo $this->config->base_url('index.php/certification/add/')"
(I believe it will work as you have it now after removing the script part from the config, but I suppose this is the 'proper CI way' of doing it)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.