Codeigniter URL not working without index.php
Asked Answered
J

4

5

I've just set up a new webiste http://www.reviewongadgets.com

But there is a problem with URL rendering

When I put an URL as below it's not working and gives page not found error http://www.reviewongadgets.com/latest-mobile

But it works with http://www.reviewongadgets.com/index.php/latest-mobile

I don't want to show index.php in my URL, it should be http://www.reviewongadgets.com/latest-mobile , can you please suggest me what should I do ?

This is my .htaccess file contents:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Config file contents:

$config['base_url'] = "http://www.reviewongadgets.com";
$config['index_page'] = "";

Same type configuration working for my another website

Changed my .htaccess content to

<IfModule mod_rewrite.c>
    RewriteEngine On

 RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Joyjoya answered 11/12, 2011 at 15:23 Comment(1)
You should share your solution with others so when they come look at this question they get the solution.Aurelie
G
5

The most common solution to this problem is usually the missing question mark ? after index.php in .htaccess, so

RewriteRule ^(.*)$ index.php/$1 [L]

should be

RewriteRule ^(.*)$ index.php?/$1 [L]

E.G. on my Windows XAMPP, I do not need the "?", but in a Linux hosting environment it is usually required.

Godroon answered 15/12, 2011 at 14:4 Comment(0)
A
5

i aggree with Vlakarados, but i will share my .htaccess setting

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

its work perfectly.

i hope that's work to for your CI website

Argus answered 17/2, 2014 at 7:17 Comment(0)
F
0

You might not have rewrite_module module loaded. Try running below command.

sudo a2enmod rewrite
Forehead answered 29/1, 2020 at 8:39 Comment(0)
T
0

In case you are on Ubuntu, edit the file /etc/apache2/apache2.conf

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

and change it to;

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

then,

sudo service apache2 restart

You may also need to do sudo a2enmod rewrite to enable module rewrite.

Taeniacide answered 11/5, 2024 at 7:16 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.