Code igniter 404 page not found error - codeigniter

I have developed a web application on code igniter. This is the first time i am working on code-igniter After developing a web application on my localhost its working fine. But when I hosted the site in server the main index page was opening but the sub pages showing "404 page not found error". Can you please guide me.Here is my htacess file
RewriteBase /
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*) index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+) index.php?/$1 [L]`
and in my routes.php I have added following line
$route['about'] = 'mycontroller/about';

Did you try setting the config ?
$config['base_url'] = "https://www.yoursite.com/";
There is a good tutorial on that at sajjad's blog

Copy the below code in your .htaccess file :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

my code had all class names starting with uppercase letter, however few posts mentioned changing the file name to match the class name. However, that didn't help. Finally the following helped:
create a file .htaccess and add the following lines of code in it:
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
it should work

Related

Not able to access other controllers

I have worked on a website which was has two domain names.It got linked to one of them on one server.On trying the same on another server for a different domain the website gets linked and opens but it is just able to access the default controller.Anything I try other then the default controller it shows page not found.
there is issue with your .htacces file
just try
your.domain.com/index.php/contorller_name/function
if it works then replace your .htaccc file at main folder with this.
RewriteEngine On
RewriteBase /your_project_path
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Codeigniter A3M Admin Controller

Hi I am trying to use CodeIgniter A3M.
I am trying to view the manage users and manage permission etc but keeps on saying error 404 I am the admin I have just created an account for my self.
This seems to be a problem with your CodeIgniter setup. All the links in A3M are already assumes that you have taken steps to remove the index.php from the path using .htaccess. You can read in the user guide on how to do that. In general you should have this in your .htaccess file in the root:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Also check that you have all other settings set correctly according to A3M.
I think you must code .htacess file like this
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Its working for me
My code .htacess
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteCond $1!^(index\.php|resource|system|user_guide|bootstrap|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php?/$1 [L]

CodeIgniter URL rewrite not working

I am trying to redirect url in CodeIgniter framework with www.hostname.com/crm/some/url to www.hostname.com/index.php?/some/url
I wrote following rule in my .htacess
RewriteEngine on
RewriteRule ^crm(.*)$ index.php?/$1 [L]
When i try this in browser, i get page not found 404 from codeIngnitor. But if add [R] flag in the redirect rules, it works proper and i could see the new url as expected after the change.
I tried apache rewrite log. Everything looks proper. I have no what URL the CodeIgniter frame sees after rewrite. Any help is appreciated.
Is there a reason you're not using the typical Codeigniter .htaccess?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
You can follow this, Do this code copy and paste in your .htaccess file. I think
it will help you.
RewriteEngine on
RewriteCond $1 !^(index\.php|(.*)\.swf|forums|images|css|uploads|themes|downloads|jquery|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php?$1 [L,QSA]

CodeIgniter - Routing doesn't work

I have a routing problem in CodeIgniter.
I can access to my default controller (the login page) with the http://localhost/MySite. So I think the routing configuration is good.
When I submit the login form of my login page, I get a Not found error 404 and the URL displayed is http://localhost/MySite/login?
When I insert "index.php" (http://localhost/MySite/index.php/login) in the url, it works. In the documentation it's written that I must add some lines in .htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L,QSA]
What is wrong with this URL Routing?
Try this thing which i am using write now in my project........
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Please try this..
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1
I hope it will be ok.

Can't access the internal pages on CodeIgniter coded website

I have a website design prototype coded in Code Igniter 2.0 and I can't access the internal pages.
Here's the link to the website prototype: http://thepbe.org/
When I try to access internal pages, the browser just displays "No input file specified."
I think there's something wrong with my .htaccess file.
Here's the code in my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1
Open application/config/config.php file and make sure these options are set.
$config['index_page'] = “”;
$config['uri_protocol'] = “AUTO“;
then change your .htaccess file to this:
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
Problem is due to absence of .htaccess file or incomplete .htaccess file.
You can use below code for .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Resources