Raghavendra Naidu
Raghavendra Naidu

Reputation: 11

loading controllers in codeigniter

For register page I have 'Register' controller

For login page, I have 'login' controller

I loaded url, form helpers

at the end of I have given login link as follows

<a href="<?php echo base_url();?>login">Login</a>

But it's showing the error.

Object not found! The requested URL was not found on this server.

Upvotes: 0

Views: 64

Answers (5)

Delwar Sumon
Delwar Sumon

Reputation: 470

Change your htaccess file to this. I think it will work.

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

And Base URL should be absolute, including the protocol:

$config['base_url'] = "http://somesite.com/somedir/";

If using the URL helper, then base_url() will output the above string.

Upvotes: 2

Mhrishad
Mhrishad

Reputation: 246

First Check Your base_url From application/Config/config.php file

Then Set Your base_url()

`$config['base_url'] = 'http://localhost/[your-project-name]';`

if your project have on root folder then set

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

Note: In Login Controller May be You find index file. If not then must be set your function name. Like this:

 <a href="<?php echo base_url('ControllerName/MethodName');?>">Login/[your-function-name]</a>

Upvotes: 1

Alex
Alex

Reputation: 9265

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

assuming your index.php is in htdocs directly and not some subfolder.

otherwise it should be $config['base_url'] = 'http://localhost/sub_folder/';

(trailing slash required)

Upvotes: 0

Atal Prateek
Atal Prateek

Reputation: 541

Have you removed index.php from url using .htaccess file? If yes the you can use <?php echo base_url('login'); ?>. Or else you should use <?php echo site_url('login'); ?>.

Upvotes: 0

NFTtray
NFTtray

Reputation: 75

<a href="<?php echo base_url('ControllerName/MethodName');?>">Login</a>

Upvotes: 0

Related Questions