2

https://stackoverflow.com/a/29562910/4713946

This is my problem, and I am not sure about the answer. I am unsure where I put this code. I cannot comment on the post itself as I do not have enough reputation so I have to start a new thread. /:

Can someone maybe help me out.

I do a redirect() and when I do this, the 'Localhost' changes to '127.0.0.1'

Community
  • 1
  • 1
Anthony Davis
  • 139
  • 2
  • 11

2 Answers2

5

So turns out all I had to do was change 'base_url' in 'config.php' file:

$config['base_url'] = '';

to

$config['base_url'] = '/';
Anthony Davis
  • 139
  • 2
  • 11
3

You should set your base url if your using codeigniter 3 versions

$config['base_url'] = 'http://localhost/yourproject/';

If base url is blank it codeigniter 3 versions will show ip_address in url instead of localhost.

  • is this the same as '/' or is there a specific reason to do it this way? because so far '/' is working ok. will it cause trouble later? – Anthony Davis Feb 25 '16 at 00:53
  • I'm unaware just having / of it causing issues but I have been told it's better to have a base_url like above. –  Feb 25 '16 at 00:58
  • When I do it this way, It does not work because it ends up: 'http://localhost/yourproject/surveys/index' maybe it is the way I have MAMP set up? EIther way, both answers are good to have on here, I am assuming it depends on how it is set up, but maybe I am wrong. All I know is it did not work for me. – Anthony Davis Feb 25 '16 at 01:27
  • If you want to get to the index function of surveys just type in `http://localhost/yourproject/surveys/'` make sure you class and file name have first letter upper case Example: `Surveys.php` and `class Surveys extends CI_Controller {}` –  Feb 25 '16 at 01:33
  • You may have to use url with index.php example: `http://localhost/yourproject/index.php/surveys/` if you have not removed it with a htaccess and on your config file. –  Feb 25 '16 at 01:34