Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Problems with .htaccess not removing index.php in URL.
#1

[eluser]Moult[/eluser]
I've searched around the forums for quite a bit and it seems as though a lot of people have encountered similar if not the same problem as I have. However, none of the fixes proposed has worked for me, hence I'm going to try and start my own thread to help solve it.

Basically, I run CI on my localhost and also on a shared webserver. It works perfectly fine on my localhost, however, on my shared webserver, there are some problems when I try to use the .htaccess file to remove the index.php from the url. Let's say I have just installed CI, I go edit system/application/config/config.php and change the base_url to http://mysite.com/ then I create a new controller with the file name other_page.php. Alright, going to mysite.com loads the welcome controller, as usual, then when I do mysite.com/index.php/other_page, it loads the other_page controller. Works fine. If I load mysite.com/other_page, I get a 404. This is working fine and as expected.

Now, I add a .htaccess file in the root dir (same dir as my index.php) with the lines:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Now, I edit my config.php again to change the index_page from "index.php" to "". (Yes, nothing), as asked by the comments in the file.
Ok. Visiting mysite.com still loads the welcome controller, that's good. Visiting mysite.com/other_page DOES NOT load the other_page controller like it should, but still loads the welcome controller. Visiting mysite.com/index.php/other_page loads fine, but it still has the index.php in the URL. What am I doing wrong?
#2

[eluser]FinalFrag[/eluser]
I'm not 100% sure this will work for you, but you can try it.
In the config file, set $config['uri_protocol'] to "REQUEST_URI".

I have had a similar problem, and this fixed it.

Let me know...
#3

[eluser]pedro_sland[/eluser]
Hi
Try adding a RewriteBase to your htaccess below RewriteOn
Usually this will work
Code:
RewriteBase /html_docs
or possibly
Code:
RewriteBase /www
#4

[eluser]Moult[/eluser]
[quote author="FinalFrag" date="1229285146"]I'm not 100% sure this will work for you, but you can try it.
In the config file, set $config['uri_protocol'] to "REQUEST_URI".

I have had a similar problem, and this fixed it.

Let me know...[/quote]

Thank you that fixed it!
#5

[eluser]FinalFrag[/eluser]
First time I'm actually able to fix someone elses problem on these forums.

Glad I could help...




Theme © iAndrew 2016 - Forum software by © MyBB