"No input file specified." in Two-Application Codeigniter - php

I've done a wide search but couldn't find a way to solve my problem.
I'm using codeigniter with two applications - one for frontend and one for backend.
My folder tree is like:
application
backend
frontend
system
index.php
admin.php
I have written htaccess file as:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|table-images|js|robots\.txt|css)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
I wanted to remove the "index.php" from URL but "admin.php" can stay, it's no problem. It works fine with frontend but when I visit /admin.php/login for example, it return "No input file specified."
In Godaddy hosting I have no problem with this htaccess, but now I must use another hosting company.
Can you please help me? Thanks a lot

I have found best way works for me copy the application folder and index.php file and create a new folder in directory called backend You may have to do little tweaking.
application folder
index.php
"backend" folder
"backend / application
"backend / index.php
also add to both config base url "BASE" $config['base_url'] = BASE_URL;
I put in main index.php also copy and paste it into the backend index.php
/*
*--------------------------------------------------------------------------
* Base URL
*--------------------------------------------------------------------------
*
* Attemtps to figure the root web address
*
*/
if (isset($_SERVER['HTTP_HOST']))
{
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
$base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
else
{
$base_url = 'http://localhost/';
}
define('BASE_URL', $base_url);
unset($base_url);

Try This htaccess and visit it this page http://philsturgeon.co.uk/blog/2009/06/How-to-Multi-site-CodeIgniter-Set-up or http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
or
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the 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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>

Related

Remove Index.php from URL in PHP CodeIgniter in Fedora 16 server

My web application doesn't work without index.php in URL. It has been working in my previous Laptop (OS: Ubuntu 10.10). In my new laptop, in OS Fedora 16 it doesn't work. I did all the checking like .htaccess, cofig.php etc. Other application rather than CodeIgniter framework like PHPMyAdmin, work fine. Following is my .htaccess code.
# 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 /barj
#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 config.php, I have the following conf
$config['index_page'] = "";
$config['REQUEST_URI'] = "AUTO";
Please give me any idea to resolve the issue.
Please check in appache configuration file that mod_rewrite module is enable or not.
You can check it by following command.
echo phpinfo();
If it is not enabled, enable it.
First try out this minimal code. It is working fine for me.
# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

Codeigniter htaccess - controllers in subfolder not working

I am new to CI and don't know much about rewrite rules. I was able to find htaccess rules from stackoverflow post which allows me to remove index.php from the URL. The ht access rules are as following
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /siebeluigen/
#Removes access to the 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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
But this doesn't work if I move my controllers to subfolder within the controller directly. for example
If I put my Application controller in following path
application/controllers/application.php
Then I can access it from URL
http://localhost/siebeluigen/application
But if my directory structure is
application/controllers/app/application.php
Then I get error with following url
http://localhost/siebeluigen/app/application
but it works like this
http://localhost/siebeluigen/index.php/app/application
So, I am pretty sure there is something in htaccess that I should be able to change to make it work.
Please help!!!
Update
My htaccess file was in the application folder instead of root. Moving the file to the folder were index.php is located solved the issue. I have marked the answer that is working.
Thanks...
This is my htaccess file that I use on ALL my projects:
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
# activate URL rewriting
RewriteEngine on
# do not rewrite links to the documentation, assets and public files
RewriteCond $1 !^(images|assets|uploads|captcha)
# do not rewrite for php files in the document root, robots.txt or the maintenance page
RewriteCond $1 !^([^\..]+\.php|robots\.txt)
# but rewrite everything else
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>
Then - also make sure that inside your config.php file
$config['index_page'] = '';
edit: you NEVER want to point someone to your application folder - you ALWAYS point them to your index.php - EVERYTHING goes through Index.php - and it does the re-routing to where it is needed.
This is the condition that is usually meant to redirect to application.php
RewriteCond %{REQUEST_URI} ^application.*
app/application doesn't match this condition. Try changing it to this:
RewriteCond %{REQUEST_URI} ^app/application.*

CodeIgniter all the pages redirecting to home page?

I have made a codeIgniter application. Its working oh so cool on my local, but when I deploy it to the main, all my pages are getting redirected to the home page.
I have the following directory structure:
---www
-----.htaccess
------codeIgniter (the application lives here).
My htaccess reads as follows
RewriteEngine on
RewriteCond $1 ^media
RewriteRule ^(.*)$ codeIgnite/$1
RewriteCond $1 !^(index\.php|codeIgnite|images|robots\.txt)
RewriteRule ^(.*)$ codeIgnite/index.php/$1
And this is my config.php
$config['base_url'] = "http://localhost/codeIgnite/"; // or should it just be http://localhost/ ?
Is there some other config settings I need to change ? Please help.
My home page shows up just fine. Problem is with other pages. No matter what URL I give, I see my home page UI.
Setting the $config['uri_protocol'] = "ORIG_PATH_INFO", fixed the issue.
I've used the provided .htaccess from CodeIgniter and just set the RewriteBase to my subdirectory to get it to work properly.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /codeIgnite/
#Removes access to the 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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
You should have to put the .htaccess in the CodeIgniter folder and also you have to modify the last line of your file to this
RewriteRule ^(.)$ /codeIgniter/index.php/$1 or
RewriteRule ^(.)$ /codeIgnite/index.php/$1
You dont have to do nothing in apache config only turn on the extension rewrite_module

htaccess configuration - With CodeIgniter - A3M library

I downloaded a3m, it comes packaged with CI 1.7.2 but I went ahead and removed all of the files it needed to run and put them in my pre-existing installation. After going to the a3m controller on my site I received:
Message: Undefined property: CI::$session
So I assume it’s because of htaccess looking for a3m files in an a3m folder, here’s the a3m htaccess:
RewriteEngine on
RewriteRule ^$ /a3m/index.php [L]
RewriteCond $1 !^(index\.php|css|img|js|scripts|system|uploads|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /a3m/index.php/$1 [L]
And my already existing htaccess for mod rewrite is as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /beta/
#Removes access to the 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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
As the commenting shows, I used it from a site a while back, so how can I combine the two I guess is what I’m trying to ask as I’m quite enthused about using a3m.
Thanks guys.
It doesn't look like you've loaded the session library.
Check in system\application\config\autoload.php if you have the library loaded:
[42] $autoload['libraries'] = array('database', 'session');
You can do this from the controller:
$this->load->library('session');
http://codeigniter.com/user_guide/libraries/sessions.html

routing problem in codeigniter

I'm new to CodeIgniter and routing.
I have a Login controller whose index() loads up a view to enter a username/password. In the view, the form has action="login/authenticate". Login->authenticate() determines if the login is valid or not. If it's valid, redirect('lobby'), if not redirect('login')
routes.php:
$route['default_controller'] = "login"
config.php:
$config['base_url'] = "http://localhost/dts/";
$config['index_page'] = "index.php";
The problem is that when i go to http://localhost/dts/ , click login, I am correctly (?) redirected to http://localhost/dts/login/authenticate but the browser says Object not found!. But when I go to http://localhost/dts/index.php/ (with trailing slash), it works correctly (I get redirected to http://localhost/dts/index.php/login/authenticate, and am logged in)
I tried removing "index.php" by using a .htaccess:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
and it would no longer open even the http://localhost/dts/
I'm confused.. what's going on?
The issue is with the last line of your .htaccess file.
Since your application is in a subdirectory ("dts"), the forward slash in front of the "index.php" won't work. Try removing it so that your file looks like this:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
Follow this article on the CodeIgniter wiki to properly setup your .htaccess as follows:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the 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]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
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
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
Did you change this in your config:
$config['index_page'] = "index.php";
To this:
$config['index_page'] = "";
Also, read this post by Jamie Rumbelow:
http://jamieonsoftware.com/blog/entry/the-best-codeigniter-.htaccess
Thats the .htaccess I've always used and it works great for me.

Categories