404 error when Uploading CI to Server - codeigniter

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>

Related

Removing index.php in Codeigniter HMVC

I am tried to remove index.php in Codeigniter HMVC. But I Could not complete with the following code.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I placed .htaccess file in root directory and removed index.php from config file. Still I'm facing the same problem.
in your config.php file put
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
Then in .htaccess file put
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
Now, check your url removing index.php. It will work.
Please follow some step:
goto application/config/config.php :
replace $config['index_page'] = 'index.php'; to $config['index_page'] = '';
and
$config['uri_protocol'] = 'REQUEST_URI'; to $config['uri_protocol'] = 'AUTO';
enable rewrite mode by
sudo a2enmod rewrite
then
service apache2 restart
if you'd like, you can use the following .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Simply create one new file .htaccess.
And past it the below code into the .htaccess file.
Then go into the project folder follow the path application->config->config.php
into the config.php file
$config['index_page]='index.php'; replace to $config['index_page'] = '';
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /example/index.php/$1 [L]
// into the above line example is the project name, you have to replace the example to your project name
RewriteBase /g-pos /// Your htdocs
RewriteEngine On
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Unable to load website on url it open when I enter **www.domain.com/controller**

I have developed the application in CodeIgnitor CI. Website id running properly on local machine.
my htaccess code is below
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ROOT DIRECTORY NAME/
# Directs all EE web requests through the site index file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
And my directory structure is
|application
|css
|js
|htaccess
|index
I have given the controller name in route.php for default_controller
Please let me know were I am wrong?
Oppz, In your file folder structurer you forget to upload system folder. It will solved all your issues.
and in config/config.php (Change this)
$config['base_url'] = '';
$config['index_page'] = '';
In .htaccess(out side the application folder) replace this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Remove index.php from URL in CI?

I removed index.php from the URL in CodeIgniter. I have already changed the .htaccess file data. But I want to know that is there any other way to remove the index.php from the URL or through any other .htaccess data. Means this is only a way or not.
In .htaccess file I wrote this :
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Try This code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
and do not forget to null index value in config file
$config['index_page'] = '';
Try this :
Make sure you have enabled rewrite_module on your Apache modules
.htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|indexcp\.php?|resources|robots\.txt)
RewriteRule ^([A-Za-z0-9_/.-]+)$ index.php?/welcome/$1
Open config.php :-
$config['index_page'] = '';
$config['base_url'] = 'http://www.example.com/'; //your site name
$config['uri_protocol']= 'REQUEST_URI';
Options +FollowSymLinks
RewriteEngine on
# Send request via index.php (again, not if its a real file or folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
<IfModule mod_php5.c>
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_php5.c>
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

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