Why does not display controller in Codeigniter? - php

I have updated Codeigniter from GitHub:
https://github.com/bcit-ci/CodeIgniter/tree/feature/session
In config.php file there is rows:
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
File .htaccess:
AddDefaultCharset utf-8
RewriteEngine On
RewriteBase /
DirectoryIndex index.php index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
When I open URL www.site.com I get message:
404 Page Not Found
The page you requested was not found.
Also I tried get controller as like:
index.php/articles/test

Are you running this version on your localhost using xampp?
I got mine working the following way:
$config['index_page'] = '';
and my .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site.com/index.php/$1 [L,QSA]

Related

Codeigniter cannot access controller without index.php

My local xampp codeigniter projec's url was
http://localhost/ci_yudeesh/index.php
But then wanted to remove the index.php part from the url so I followed the steps given in the userguide.
After that i could access the project without index.php with the url
http://localhost/ci_yudeesh/
I have a controller named Home and I can access this using http://localhost/ci_yudeesh/index.php/home
, but when try to access this using http://localhost/ci_yudeesh/home it gives this error:
this is my config:
$config['base_url'] = 'http://localhost/ci_yudeesh/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
this is my .htaccess:
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
this is my route:
$route['default_controller'] = 'Home';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
Can someone help me fixing this? I tried all the other answers to similar type questions but none worked.
Remove the .htaccess from the application folder and put it outside the application folder and written only the below code in it. If it not work then I will give you another .htaccess code.
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Change the .htaccess file . Remove the codes from the existing file and add the following codes on the file :-
RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteBase /ci_yudeesh/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Removing index.php from CodeIgniter URL

I'm struggling with removing the 'index.php' part of my CodeIgniter URL.
I'm using CodeIgniter version 3.1.2. I've followed all steps on other questions about this:
Changed $config['index_page'] = 'index.php' to $config['index_page'] = ''
Changed $config['uri_protocol'] = 'AUTO' to $config['uri_protocol'] = 'REQUEST_URI'
Added a .htaccess file in the root folder of my project with the following code:
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
However when I try to access my site, I get the following error code.
Not Found
The requested URL /Toneel/Site/index was not found on this server.
The rewrite module is turned on in my Apache Server.
Can anyone help me out with this issue?
This setting worked for me.
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
To allow overriding htaccess in Apache Configuration you have to edit and change /apache2.conf file to
AllowOverride All
And restart server.
Try this code in .htaacess:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]
Try this in your .htaccess file
RewriteEngine On
RewriteBase /yourfolderhere/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
In my case, it works with:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project-name
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
** Important, this should be in an .htaccess file in the root of your project.
In config should be like this:
$config['base_url'] = 'http://your-url-here/';
$config['index_page'] = '';

.htaccess file does not working on godaddy server

Can someone tell me why this code would work on my local server but not on godaddy server?
I get the following error on godaddy...
I have creating one codeigniter project and host on godaddy server but .htaccess file does not working
my problem is "https://www.tripbrip.com/index.php/home/app_view" this same url come in my url side but i want to remove index.php in this link
my directory structure is this:
Options +MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ index.php/?$1 [NC,L]
my config file:
$config['base_url'] = "https://".$_SERVER['HTTP_HOST'].'/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
This file run in my localhost but not working on server.
I have use many code but still problem remain same .
If I browse to http://example.com/bootstrap.php I get a 404 resource not available at /
Maybe u can try put this on your .htaccess
<IfModule mod_rewrite.c>
#RewriteEngine on
#RewriteBase /
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .* index.php/$1 [PT,L]
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And for your config file. maybe u can just empty it.
$config['base_url'] = '';
If still error, you can try this
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('#/+$#', '', dirname($_SERVER['SCRIPT_NAME'])).'/';
The following setting works fine for me.
RewriteEngine on -MultiViews
Options All -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
in application => config => config.php
$config['index_page'] = ''; // should be blank
instead of
$config['index_page'] = 'index.php';

Remove index.php from codeigniter in subfolder

My codeigniter is installed in admin_new folder on hostinger and path of installed codeigniter is public_html/vishwa/admin_new/ and i am trying to remove index.php from url.
I have changed my .htaccess file as below.
RewriteEngine on
RewriteBase /vishwa/admin_new/
RewriteRule ^(application|system|\.svn) index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
I have checked forums and it says mode_rewrite is enabled as default on hostinger. but it is showing error like No input file specified.
I have also changed config settings in config.php as below:
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
but still it is showing same error. Why this type of error has been shown and how can i solve it.
try this
RewriteEngine on
RewriteCond $1 !^(index\.php|public|\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1

codeigniter, 404 not found error

I have a web site and I have installed CodeIgniter 2 Site under sub folder (test)
Users can access the site by using following link:
http://www.example.com/test/
When user is going to access (test) site using above link URL redirected to following link and following error will displayed.
http://www.example.com/test/login
Not Found
The requested URL /test/login was not found on this server.
Then I add index.php to the above URL, login page displayed.
http://www.example.com/test/index.php/login
When I submit my username and password again URL redirected to, without logged on.
http://www.example.com/test/login
And again, not found.
.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
config.php:
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = "AUTO" ;
I have tried $config['base_url'] = "http://www.example.com/test" - still not working.
in config/config.php
$config['base_url'] = 'https://stackoverflow.com/';
$config['index_page'] = '';
in .htaccess (place outside application folder)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
replace .htaccess with this code
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
try this in your .htaccess
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]

Categories