Codeigniter installed at subdirectory showing 404 error - .htaccess

I have installed two codeigniter in my server. One is the root of the domain and for second I've creates one new folder and installed second codeigniter there. When I am trying to access the folder, it shows error 404.

You should define base url for sub directory in your config
You can get Idea from following example code
$config['base_url'] = http://example.com/sub;

Try this Set you default base url for subdirectory
$config['base_url'] = "http://www.example.com/sub/"
Open config.php and do following replaces
$config['uri_protocol'] ="AUTO"
by
$config['uri_protocol'] = "REQUEST_URI"
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
This code run all sub directory. Hope this will help you!.

Related

After activating htaccess in cpanel I can't log in again to my codeigniter app

I'm using cpanel as online server, Initially before activating htaccess file i was able to login but after activating it I can't login again.
I don't know how to deactivate htaccess in cpanel and also i cant see httpd in cpanel. Any advice.
MY APPLICATION IS LOCATED IN SUBDOMAIN AS : example.com/project/social. where example.com is the main domain, project is a sub domain and social is a folder containing codeigniter folders.
.htaccess located in social folder also is here below
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /social/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
config.php is here
$config['base_url'] = 'http://project/social/';
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'QUERY_STRING';
When i try to login via login page the following message is desplayed
From project
Hay un error en el inicio!
Any advice please
The problem solved, the source of problem was a single line in codeigniter in config.php file, here it is
$config['uri_protocol'] = 'REQUEST_URI';
I was able to detect the source of problem after running my application by using localhost.
Then I changed that line to
$config['uri_protocol'] = 'QUERY_STRING';
after that the problem disappeared.

CodeIgniter 3.0.0 Project doesn't work on sub domain

I created a project using CI(version 3.0.0), and it works perfectly in XAMPP localhost. And i upload that project to sub domain then its giving an error Click here.
I Handle Router's and config setting as well. So what is this error?? how to avoid this?? There are some answers, But not suit for this.
Config.php
$config['base_url'] = '';
$config['index_page'] = '';
Routes.php
$route['default_controller'] = 'shop';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
.htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Change the name of your controller, model, and other your class to Capitalize.
Example :
your own controller test.php change to Test.php
It should be work.
Its because your server is Linux, and Linux is case sensitive.

Removing index.php on CodeIgniter 2.2.0

I am running Apache 2.2.22 on Ubuntu 12.04.3 (Oracle VM on Windows 8.1).
Using the PHP phpinfo() function I see mod_rewrite in the apache2handler section under Loaded Modules, so mod_rewrite is enabled.
I made the following changes to my CI config file (application/config/config.php),
$config['index_page'] = 'index.php'; to: $config['index_page'] = '';
$config['uri_protocol'] = 'AUTO'; to: $config['uri_protocol'] = 'PATH_INFO';
I have tried numerous versions this(.htaccess file located in the root directory of CI ):
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
but have yet to get it to work.
What else am I missing here?
This worked!
RewriteEngine On
RewriteBase /testsite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Working on the assumption that your folder structure is something like... /var/www/html/testsite and your url is localhost/testsite, then the above rewrite rule will be looking for index.php in /var/www/html and not /var/www/html/testsite.
( /var/www/html will be the default document root. )
So in your equivalent folder of /var/www/html/testsite you can try using the following in your .htaccess file located in /var/www/html/testsite/. so you'd have /var/www/html/testsite/.htaccess with the code...
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
All I have done is removed the leading / in the rewrite rule in the last line so it's not heading back to the default document root.

Puzzled using codeigniter on shared hosting server

This ones a new on me. I'm transferring a site I made in codeigniter to a godaddy shared hosting server. I can get to the home page with:
http://www.example.com
But when I try to go to the other pages like:
http://www.example.com/about-us/
It throws me this error message:
Not Found
The requested URL /example/index.php/about-us/ was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
If I use:
http://www.example.com/index.php/about-us/
The page appears as clear as day.
I have looked up CI workaround , but my site is more of static pages then dynamic pages.
Overall, my question is, what am I doing wrong and does this have anything to do with having a godaddy shared hosting account?
.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
CI Config file
$config['base_url'] = '';
$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';
CI autoload file
$autoload['helper'] = array('url');
09-30-2011 Update:
In the .htaccess use:
# Options
Options -Multiviews
Options +FollowSymLinks
#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /
#Removes access to CodeIgniter system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css
#folders, and the robots.txt file
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
In the CI config file:
$config['index_page'] = "";
$config['uri_protocol'] = "AUTO";
Source: codeigniter.com/wiki/Godaddy_Installaton_Tips
It's an .htaccess issue. Try changing your .htaccess file to:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L]
Your updated .htaccess is right. you need a small change in it.
change below line in your .htaccess file:
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
and in your config.php
$config['uri_protocol'] = 'QUERY_STRING';
This is not a godaddy solution, but same error on my WAMP localhost...
I had a simple fix to this, which started to occur after I upgraded my WAMPserver. It had set up a new apache config and it had turned off the rewrite_module.
To fix, I just left click wamperver icon->Apache->Apache Modules->rewrite_module and make sure that is ticked.

Codeigniter mod rewrite in CentOS

I am trying to set up my project (built in Codeigniter) in Apache/2.0.52 (CentOS) Server.
Everything works perfectly on my local XAMPP server but on the live server, when i try to access pages like myproject.com/agents, it shows
'The requested URL /home/virtual/site777/somefolder/var/www/html/index.php/agents was not found on this server.'
The rewrite rule that I've got at the moment:
RewriteEngine on
RewriteCond $1 !^(assets|favicon\.ico|robots\.txt|index\.php) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
I have following settings in my application/config.php file
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
I would really appreciate if someone could help me.
Thank you!
On my CentOS I only have this:
RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|resources)
RewriteRule ^(.*)$ index.php/$1 [L]
But my site resides in /var/www/html. I am by no means an expert on Apache, but perhaps you need to set the
RewriteBase /home/virtual/site777/somefolder/var/www/html/
As well
Thank you all for viewing and answering my question.
I was able to solve my problem using RewriteBase in htaccess file.
you have to enable url rewriting module of apache.

Resources