Nginx rewrite rules for codeigniter - codeigniter

Earlier my web server worked on Apache, now only at Nginx.
I tried rewrite all rules for this example:
http://www.farinspace.com/codeigniter-nginx-rewrite-rules/
But still all URL same as:
mysite.com/stocks
dont work.
Where stocks - is name of controller Codeigniter.
In .htaccess file were the next rules:
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
And config.php had the following content:
$config['index_page'] = '';
$config['uri_protocol'] = "REQUEST_URI";

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 Deployment

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

Resources