CodeIgniter Forums
Removing index.php not working on hosting althougt all conditions true - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Removing index.php not working on hosting althougt all conditions true (/showthread.php?tid=74400)



Removing index.php not working on hosting althougt all conditions true - futureisnow - 09-18-2019

Hi, 
first of all I know that is a famous problem and I have already tried probably everything and I am just tired after 4 days of fighting. I feel stupid asking that as the next but I am really desperate.

The thing is: 
Removing index.php from URL works fine on localhost (XAMMP) but does not work on hosting (OVH, Apache) i.e. http://example.com/index.php/contact works fine while http://example.com/contact does NOT work.

On the server I set "root folder" into "public" folder and it seems working.

My application is:

  1. Manually installed CI4 RC1
  2. One dummy view added (contact.php) to test url + its routing 
  3. App.php: 
  • $baseURL = "http://example.com/" 
  • $indexPage = ''

The original .htaccess in "public" folder didn't work on the hosting.

A dummy .htaccess like:

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

...also does not work (neither in "public" nor in "/" folder).

I can see only a message "File not found." when I choose 


Important is that my hosting provider told me "rewrite_mod" work correct on the server.

Does anybody know what problem can be?

Should .htaccess be placed in "public" or in "/"?

Best Regards!


RE: Removing index.php not working on hosting althougt all conditions true - dave friend - 09-18-2019

It should be in public.

If you installed CodeIgniter in a subfolder, you will need to set RewriteBase appropriately.


RE: Removing index.php not working on hosting althougt all conditions true - futureisnow - 09-18-2019

(09-18-2019, 01:36 PM)dave friend Wrote: It should be in public.

If you installed CodeIgniter in a subfolder, you will need to set RewriteBase appropriately.

I tried to manipulate with it, but received only "500 Internal Server Error".

Well, it is preconfigored by hosting multipage version, so the app is in a subfolder in fact. But since it is preconfigured on the server I don't think it is a problem.


RE: Removing index.php not working on hosting althougt all conditions true - unromantic - 09-18-2019

Hey I found I solution I hope it will work for you.

create new file on root index.php and add below code :

<?php include "public/index.php"; ?>

now copy your .htaccess file from public and put it on root and thats all
it worked for me.