0

I created a site in PHP using CodeIgniter framework. When it was done, I edited routes.php file and added .htaccess file to eliminate /index.php/ part from URL.

Now, when I try to open it in localhost, it works fine, I can access http://localhost/mysite and get the landing page I wanted.

But, the problem is when I try to access the site on server, I get an error. So if I open something like http://mysite.com I get CodeIngniters' default 404 page. I can open all other pages if I specify their URL, like: http://mysite.com/about but when someone else opens the site, he gets an error and he doesn't know what to type in order to pass by that error.

What should I do to fix this? Thanks in advance.

EDIT: .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [NC,L,QSA]
Misa Lazovic
  • 2,805
  • 10
  • 32
  • 38

3 Answers3

0

This .htaccess code works for me always, you can try this:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Kalpesh Patel
  • 2,772
  • 2
  • 25
  • 52
0

Your .htaccess does raise some concerns, you are attempting to pass the file location as a query string which may work in CodeIgniter but there is a better way of doing this.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php [L]

Also, make sure in your config.php you have the following option set:

$config['uri_protocol'] = 'REQUEST_URI';

Good luck.

JakOR
  • 9
  • 1
0

This .htaccess code works

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

And in config

$config['index_page'] = '';
Miomir Dancevic
  • 6,726
  • 15
  • 74
  • 142