Welcome Guest, Not a member yet? Register   Sign In
No URI present. Default controller set
#1

(This post was last modified: 07-14-2015, 03:00 PM by drhowarddrfine.)

Sorry for the multiple threads but I'm being pressured.

In application/config/config.php, the Base Site URL line is set as: $config['base_url'] = 'http://'.$_SERVER['SERVER_NAME'];
But I get the error "No URI present. Default controller set." and a blank page. If I echo the value of '$config['base_url']' it returns "localhost" which I presume is incorrect since I'm running the server on a local computer but in a VM (VirtualBox) and accessing it from outside the VM.

If this is the problem, what do I do to fix it?

I need to warn that the code I'm working on was written for CI version 2.1.3 and I'm running it on Linux with the latest versions of mySQL and PHP.
Reply
#2

base_url should be blank, or have a / at the end (missing in yours) like the note right above where you set base_url states: http://example.com/
Reply
#3

(This post was last modified: 07-14-2015, 05:55 PM by drhowarddrfine.)

(07-14-2015, 05:20 PM)CroNiX Wrote: base_url should be blank, or have a / at the end (missing in yours) like the note right above where you set base_url states: http://example.com/

I understand that but this is taken from a working (elsewhere) web site that we own. I'm trying to take the exact copy and place it on another server. 
Reply
#4

The value of $_SERVER['SERVER_NAME'] is set in your server config file.  Check what the actual setting is.

If it is blank or cannot be resolved, the server will make some "guesses" and try to return something to the request.

You may need to put the terminating slash on the string.

You can also try to echo the value to screen, but I can't guarantee that the code will execute and push the value to the output stream.

<?php
echo $_SERVER['SERVER_NAME'[;
?>

Since you are running this under a different server, the server config file probably does not match that of the original server.  If you have access, check the server config file on the original.


Which server is being used?  Apache?  If so, are you using a virtual host file(s)?  They may override your server config file setting.  Again check the original server virtual host files.

As CroNIX noted, check your Hosts file, usually as /etc/hosts
CI 3.1 Kubuntu 19.04 Apache 5.x&nbsp; Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#5

(This post was last modified: 07-15-2015, 04:24 AM by drhowarddrfine.)

I'm using nginx. The hostname is "bob". I'm not sure what to set in /etc/hosts. I tried putting it on the same line as localhost and then tried putting it on its own line with the IP address "10.xxx.xxx.xxx bob", neither changed anything.
Reply
#6

I've no experience with nginx, so I can't advise on what may be different from my Apache server.
For Linux, this is a good description of the configuration of a local (Apache) server. Note that it may vary from your VM server installation:

https://www.digitalocean.com/community/t...-14-04-lts

Basically, your /etc/hosts file should include a line with the IP address of your site (or the FQDN), as descibed in the link above.

Sorry, but that's about as much as I can offer due to my own inexperience with your VM setup.
CI 3.1 Kubuntu 19.04 Apache 5.x&nbsp; Mysql 5.x PHP 5.x PHP 7.x
Remember: Obfuscation is a bad thing.
Clarity is desirable over Brevity every time.
Reply
#7

(This post was last modified: 07-15-2015, 07:53 AM by drhowarddrfine.)

I found one dumb thing I did. I had the hostname for the server set in a comment so that's why it would report as 'localhost' instead of "bob" but changing that didn't fix the problem except, now, echoing $_SERVER['SERVER_NAME']; gives me "bob" instead of 'localhost'. I still get the error of "No URI present".

I tried setting $config['base_url'] to nothing, '', to just slash, '/', and 'http://10.xxx.xxx.xxx/' to no avail. I'm still stuck.

In this original config, $config['index_page'] is set to '' but this is an existing, working site so I'm hesitate to blame that. I did try setting it to 'index.php', again to no avail.

EDIT: I'm able to view php_info and a html file I put in the root directory of CI and view that in the browser.
Reply
#8

'No URI present. Default controller set.' is a debug message logged by the router when the default controller is set. It's not necessarily an indication that an error has occurred.
Reply
#9

Then I'm wondering why my default controller is not showing the home page.

This leads to one of my original questions, is all this a problem caused by the fact that I'm trying to run code built on version 2.1.3 but using the latest PHP and mySQL?
Reply
#10

If you take a look at the changelog for CodeIgniter 2.2.3, you'll see that there have been a few updates specific to fixing issues with newer versions of PHP. In most cases, if you have error reporting enabled, you should receive some sort of error message telling you what's wrong. I don't remember any significant difficulties in upgrading from 2.1.x to 2.2.3, though I went through most of them one at a time (rather than all at once).
Reply




Theme © iAndrew 2016 - Forum software by © MyBB