Reputation: 4478
I m having strange problem. I have a Codeigniter application which perfectly works fine in my local machine, but in remote server it doesnot. Following are the scenarios
Some links with trailing slash works, but without trailing slash shows "The connection was reset" error in Firefox.
Some links WITHOUT trailing slash works, but WITH trailing slash shows "The connection was reset" error in Firefox.
I m sure there is no error in coding because. All I think the culprit is .htaccess file. Following is my .htaccess file
RewriteEngine on
RewriteBase /demo/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Any help will be highly appreciated. Thanks!
Upvotes: 1
Views: 1839
Reputation: 446
I believe your issue is a missing '?' on this line:
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Add this '?' directly after 'index.php'
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
Also, in my experience I would leave off the trailing slash on RewriteBase and add it to the $config['base_url'] parameter and let CI do that work for you instead:
$config['base_url'] = 'http://yourwebsite.com/demo/';
-instead of-
$config['base_url'] = 'http://yourwebsite.com/demo';
This is the .htaccess setup i've used for a while with CI and it has served me well:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase / # TODO: add a folder name here if the application is not in web root
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Upvotes: 6