Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting BaseURL for Codeigniter

I set my baseurl to:

http://localhost/codeigniter/

in the application/config/config.php file as asked by the installation instructions.

I was following this tutorial. However, when I type in the url: http://localhost/codeigniter/index.php/pages/view , I get the the following error:

Object not found!

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

If you think this is a server error, please contact the webmaster.

Error 404

localhost 7/27/2012 11:14:39 PM Apache/2.2.12 (Win32) DAV/2 mod_ssl/2.2.12 OpenSSL/0.9.8k mod_autoindex_color PHP/5.3.0 mod_perl/2.0.4 Perl/v5.10.0

I found the following contents in .htaccess file in the path of E:\WEB D\xampp\htdocs\CodeIgniter_2.1.2\application:

Deny from all

I am totally new to the CodeIgniter framework. Can someone help me out?

like image 407
kamalbhai Avatar asked Jul 27 '12 17:07

kamalbhai


People also ask

How do you write a base URL?

Base URL should be absolute, including the protocol: $config['base_url'] = "http://".$_SERVER['SERVER_NAME']."/mysite/"; This configuration will work in both localhost and server.

What is php echo Base_url ()?

php echo base_url(); This function returns the same thing as site_url() , without the indexPage being appended. Also like site_url() , you can supply segments as a string or an array.

What is Base_url in CodeIgniter?

base_url() is the URL of your CodeIgniter root or the location of the index. php file along with a trailing slash appended to the end of the URL. If the domain name is example.com and the website is using HTTPS as well as www. Further, the index.

What is the difference between Site_url and Base_url?

Basically one can use site_url() while creating links for controllers whereas base_url() can be used where we need to create urls for the assets like loading a css or js file or some image .


2 Answers

Ok, well for anyone wondering the final solution to this was that the directories were not properly named. When creating a local server it is important to put the contents of the files in the correct folder.

So if you have http://localhost/codeigniter then the directory should be setup as \path\to\webdirectory\root\codeigniter or in this case: E:\WEBD\xampp\htdocs\codeigniter

like image 134
MasterGberry Avatar answered Oct 30 '22 00:10

MasterGberry


try edit your .htaccess file became like this below, and put .htaccess file in your root application folder

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
like image 20
mmx233 Avatar answered Oct 29 '22 23:10

mmx233