CodeIgniter Deployment - codeigniter

MySite in my PC is http://localhost:8080/MySite/MyController
when I deploy to hosting server, I can only access
http://subdomain.MyDomain.com/MySite/MyController but not http://subdomain.MyDomain.com/MySite/MyController/AnyFunction (it gave 404 error)
I have created .htaccess to remove index.php, it works fine in my PC;
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
I also set $config['uri_protocol'] = 'REQUEST_URI';
Local setting:
$config['base_url']='http://localhost:8080/MySite/';
$config['index_page'] = '';
Hosting setting:
$config['base_url']='http://subdomain.MyDomain.com/MySite/';
$config['index_page'] = '';
Can anyone advice where have I gone wrong?
TIA.

Maybe you need to add a question mark to your rewrite rule:
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
source: http://codeigniter.com/forums/viewthread/181440/#862893

Related

CodeignIter with HTTPS page not rendering domain/H.html not working(404 Error)

Website is normally working without HTTPS.
with HTTPS only homepage is working but other pages like (https://domain.in/contact.html) not working(404 Error Page)
My Files.
application/config/config.php
$config['base_url'] = '';
$config['index_page'] = '';
.httaccess file is
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Please suggest me what to do.
Thanks in Advance.

404 error when Uploading CI to Server

I got an error when hosting my CI project, it success in localhost. I have change my
old
$config['base_url'] = 'http://localhost:8000/myweb'; in config.php to
new
$config['base_url'] = 'http://myweb.com';
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
this is the error :
404 Page Not Found
The page you requested was not found.
Did I miss something?
Make sure the mod_rewrite is enabled, in case of Apache server!
To enable mod_rewrite:
a2enmod rewrite
Then:
service apache2 restart
In application/config/config.php set:
$config['index_page'] = '';
.htaccess exemple:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Remove index.php from Codeigniter URL in Wamp

I have big problem trying to remove index.php from url's
i have searched lots if forums (this also), but no help for my situation.
so i have config.php file
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
my .htaccess file in public_html folder near index.php.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
i have rewrite_module ON (and it's working) and my httpd.conf AllowOverride set to All
so when i am going to mydomain.com/controller/action - I get 404
but when i go to mydomain.com/index.php/controller/action - everything is OK..
i have tried lots of .htaccess examples... and so on.. nothing helps..
.htaccess (This should be place outside application folder)
Paste this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Note : Sometime index.php will not remove in windows. But if you upload it to server it will work fine. This happen me too in XAMPP but if i upload it to host(Linux) it works fine
My Config which is working fine :
config.php
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
.htaccess
# index file can be index.php, home.php, default.php etc.
DirectoryIndex index.php
# Rewrite engine
RewriteEngine On
# condition with escaping special chars
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

after removing index.php from url in codeigniter

My login Controller : $this->load->view('login-view');
My link that redirects to 'login-view' is in the template is: anchor('login','Login');
Before removing index.php from url in codeigniter works well. But after removing index.php from url it is not working.
My .htaccess file is :
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
hard to expalin i think, Thats all i have got. :(
Try this in .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
And in config.php
$config['uri_protocol'] = 'AUTO';
Just remove index.php from your config file.
$config['index_page'] = "index.php";
should be
$config['index_page'] = "";

Codeigniter URL not working without index.php

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>
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.
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
You might not have rewrite_module module loaded.
Try running below command.
sudo a2enmod rewrite

Resources