0
votes

Im developing a simple php project using codeigniter. My htaccess looks like this

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

my base url is

$config['base_url'] = 'http://localhost/Achalaweerasooriya.github.io';

My index page is

$config['index_page'] ="";

my main controller class is LoginController.

When I run the project it calls the login controller and the url is

http://localhost/Achalaweerasooriya.github.io/index.php

this shows the login form. When I enter the logn details and click login it should validate the user. The href I've given for the login button is

href="<?php echo base_url('');?>LoginController/validate"

Then the url is displayed as

"http://localhost/Achalaweerasooriya.github.io/LoginController/validate"

which is logically correct.

but when I click the login button with correct username and password 404 error is generated saying object not found error says "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 Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.5.30"

but if I add index.php manually to the url (then the url looks as "http://localhost/Achalaweerasooriya.github.io/index.php/LoginController/validate"), then the correct page is displayed. As a solution I added index.php to the base url so that it looks like

$config['base_url'] = 'http://localhost/Achalaweerasooriya.github.io/index.php';

But then as ive used the base_url(); call to link the external css and javascripts, they stop responding as they should.

Please point me in the correct direction.Thanks in advance.

2
don't put index.php $config['base_url'] = 'http://localhost/Achalaweerasooriya.github.io/'; - Mr. ED
That doesnt change anything.automatically it gets index.php when running - Achala Weerasooriya
what you using wamp or xampp - Mr. ED
Can you try to comment the two REQUEST_FILENAME conditions ? - Gwendal
Make sure your Apache configuration allow .htaccess (check for AllowOverride in httpd.conf) otherwise your .htaccess file is ignored - Zamrony P. Juhara

2 Answers

0
votes

If your .htaccess file is working then remove old code lines related to index.php and add below code

Or just make .htaccess blank and try below code. It worked for me.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php?/$0 [QSA,L]
</IfModule>
0
votes

Remove index.php from $config['base_url'] and try this

http://addictors.in/remove-index-php-from-url-in-codeigniter/

and also restart server