Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

routing issue in localhost in codeigniter

I have this URL: http://localhost/fixbud/ as my home URL. My page is rendering fine. But when I go to another link like: http://localhost/fixbud/answer_forum I get error 404.

Here are my routes:

$route['default_controller'] = "fixbudd";
$route['404_override'] = '';
$route['index'] = "fixbudd/index";
$route['answer_forum'] = "fixbudd/answer_forum";

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

config

$config['base_url'] = 'http://localhost/fixbud/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

Can you tell me the rules in routing URL and how to solve my problem? I am using CI2

like image 201
easydev Avatar asked Sep 12 '25 12:09

easydev


2 Answers

I had the same problem and added this to apache config solved it.

   <Directory "<to your project">

       Options Indexes FollowSymLinks MultiViews

       AllowOverride All

      Order allow,deny

      allow from all

      Require all granted

</Directory>

source http://acmeextension.com/remove-index-php-in-your-codeigniter-project/

like image 125
Smiled_One Avatar answered Sep 15 '25 15:09

Smiled_One


This happens because of the .htaccess file, I prefer making new .htaccess file for local env and add the following code.

RewriteEngine on

RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)

RewriteCond %(REQUEST_FILENAME) !-f

RewriteCond %(REQUEST_FILENAME) !-d

RewriteRule ^(.*)$ ./index.php/$1 [L]
like image 38
Muhammad Binyameen Malik Avatar answered Sep 15 '25 15:09

Muhammad Binyameen Malik