Codeigniter - no input file specified - codeigniter

I am a beginner in Codeigniter and I saw a CI tutorial and was just trying to do a simple thing. I downloaded the CI and added this file to controller directory, but it won't work.
<?php
class site extends CI_Controller
{
public function index()
{
echo "Hello World";
}
function dosomething()
{
echo "Do Something";
}
}
?>
When I try to access it using http://..../index.php/site I get the output ... "no input file specified" .... by the way, I named the file site.php

Just add the ? sign after index.php in the .htaccess file :
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
and it would work !

Godaddy hosting it seems fixed on .htaccess, myself it is working
RewriteRule ^(.*)$ index.php/$1 [L]
to
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]

I found the answer to this question here..... The problem was hosting server... I thank all who tried .... Hope this will help others
Godaddy Installation Tips

RewriteEngine, DirectoryIndex in .htaccess file of CodeIgniter apps
I just changed the .htaccess file contents and as shown in the following links answer. And tried refreshing the page (which didn't work, and couldn't find the request to my controller) it worked.
Then just because of my doubt I undone the changes I did to my .htaccess inside my public_html folder back to original .htaccess content. So it's now as follows (which is originally it was):
DirectoryIndex index.php
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]
And now also it works.
Hint: Seems like before the Rewrite Rules haven't been clearly setup within the Server context.
My file structure is as follows:
/
|- gheapp
| |- application
| L- system
|
|- public_html
| |- .htaccess
| L- index.php
And in the index.php I have set up the following paths to the system and the application:
$system_path = '../gheapp/system';
$application_folder = '../gheapp/application';
Note: by doing so, our application source code becomes hidden to the public at first.
Please, if you guys find anything wrong with my answer, comment and re-correct me!
Hope beginners would find this answer helpful.
Thanks!

My site is hosted on MochaHost, i had a tough time to setup the .htaccess file so that i can remove the index.php from my urls. However, after some googling, i combined the answer on this thread and other answers. My final working .htaccess file has the following contents:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|app_upload|assets|css|js|images)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php?/$1 [PT,L]
</IfModule>

One of my Codeigniter apps started returning this error after i restarted my server.
When I checked the Codeigniter error log it says something like:
"...[error] 879#0: *273 FastCGI sent in stderr: "PHP message: PHP Warning: Unknown: open_basedir restriction in effect. File(/pathToWebsiteRootFolder/index.php) is not within the allowed path(s): ".
So I added this:
open_basedir= /pathToWebsiteRootFolder/index.php:
To a user.ini file I created in my website root folder.
And this Solved it.
FYI: Im using an NGINX web server.
However, Its strange because I didn't have to do this for the other Apps on the same server.

Related

YOURLS: 404 and directory issues

My main domain is smile.ws
I have installed yourls in smile.ws/yourls.
As a result, all my shortened urls are smile.ws/yourls/link instead of smile.ws/link
I followed the wiki instructions but that didn’t help.
I looked around and found a plugin called "Swap Short Url" which is supposed to help in these situations. It has slightly different .htaccess recommendation. I followed the instructions correctly and it works, because now the urls are smile.ws/link. But when you click on them, you get a 404 error.
How can I fix this? Thanks!
PS I know this is not a programming question. However, Stackoverflow has a tag for YoURLS that has 55 questions.
This to me sounds like it is related to the web servers .htaccess file but I can't be certain unless you can give us an example. I have a YOURLS site that work as you are describing without using a plugin. This really comes down to how the web server is configured and the YOURLS settings. Here is a sample of my .htaccess file.
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /yourls-loader.php [L]
</IfModule>
# END YOURLS
In your config file this line needs to look like this.
define( 'YOURLS_SITE', 'http://smile.ws' );
If this doesn't work it might be due to your web server not having the correct permissions set or the rewrite module not enabled assuming you are using apache.
Did anyone check the root .htaccess?
# BEGIN YOURLS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /YOURLS/yourls-loader.php [L]
</IfModule>
# END YOURLS
This line needs to set the subdirectory /your dir here/
RewriteRule ^.*$ /YOURLS/yourls-loader.php [L]

Laravel migrations issue - remove the word 'public' in url

I moved my laravel instance to a new server.
I have updated the env file and the database connection file and the instance is working with the small exception of the url.
When I type the url: https://domain-name.com
"Forbidden
You don't have permission to access / on this server.
Apache Server at domain_name.com Port 443"
When I type: https://domain-name.com/public (I have to use the domain/public convention on all routes)
It all works fine. I have searched the forums etc and there are a few proposed solutions, none of which seem to work (The solutions range form updating the .htaccess file, to registing the url in the bootstrap/app.php files) none of which are making a difference.
Has anyone experienced this issue and can recommend a fix?
I have experienced this one, but I don't know if this will work for you.
1) Navigate to bootstrap folder and delete all the contents inside the cache folder.
2) Create an .htaccess file to your project's directory. If .htaccess file is already present, proceed to Step 3. You don't need a duplicate one.
3) In the .htaccess file, copy and paste this code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
4) Navigate to public folder (not the public_html folder). Public folder is present inside your Laravel's project. Create an .htaccess file and paste this code. Again, if .htaccess file is already present, just edit that file and copy the code below.
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
5.) That's it. Hopefully, this one will for you. Cross fingers

codeigniter page not found on live server

codeigniter page not found showing but working fine in local server.
I had uploaded codeigniter file of one basic simple page on live server but there it is showing no page found and same file it is working on local server.
In that I had
mine.php ---- controller
index.php --- view
I loaded in routes default controller - mine in config base url- domain.com removed index.php also
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
can I know please why it is showing page not found, might be some routing issue but I had loaded default controller also. Please help out on this
First of all start error logging properly so you can see the actuall error.
Change your file name's first letter capital. This is mendetory as explained here ci3 manual - controllers. It says class name as well as file name must start with capital. ( If your Dev machine is windows then it will not show errors if you don't follow this rule. Because window's file system is case insensitive. But on your server it is linux.so it will show error)
If you still don't get it working then try access the url with index.php in it. Temporaryly disable .htaccess .If you get it working then may be you have problem in . htaccess. Try the following link to properly remove index.php from your url. Expression engine forum .This htaccess worked for me on all different server I have used.
add this in .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|images|asset|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

.htaccess URL rewriting for CodeIgniter not working

I have the following .htaccess in /home/domain/public_html/subfolder
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|user_guide|robots\.txt)
RewriteRule ^(.*)$ public/index.php?/$1 [L]
But this doesn't work http://domain.com/subfolder/
File does not exist: /home/domian/public_html/public
I apparently have my rewrite rules messed up. This entire CI application is in a subfolder of the web root.
/home/domain/public_html/subfolder
[sssss#ff subfolder]$ ls
application license.txt public system user_guide
and index.php is in public.
First, your index.php should be in the same directory as application and system.
Once you moved it, try this in your .htaccess
RewriteEngine on
RewriteBase /subfolder/
RewriteCond $1 !^(index\.php|user_guide|robots\.txt)
RewriteRule ^(.*)$ index.php?/$1 [L]
Also on an unrelated note, I'd delete the user-guide directory since everything it contains is accessible at on the CodeIgniter Site.

codeigniter 404 on existing controller

I am facing a different problem in codeigniter.
When I try to access the videos page in my site, it will redirect to 404.shtml page. But cvideos.php file exists in my controllers folder.
If I access like this http://domain-name/videos , then it will be redirected like this
//domain-name/500.shtml
And If I access the same page like this //domain-name/videos/myvideos, then then it will be redirected like this
//domain-name/404.shtml
Also, If I change the controller name from videos to some other name like videoss it works fine. Can anyone tell wats the issue.
I used this line in my .htaccess also just for testing. But no use.
RewriteRule ^videos/$ index.php/videoss/ [L]
Your controller needs to be the same name as the class it contains.
hence -
<?php
controller Videos extends Controller {
/* bla */
}
?>
should be saved as:
videos.php in the "controllers" directory.
Nothing else will work.
also your rewrite rule has two "s"'s, but that might be intentional.
and it looks like what you are trying to do with .htaccess can be achieved with CI's routing
Edit: .htaccess
<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>
please note I did not create this - it was found by scouring the CI forums. It's a rather thorough htaccess however.
Don't forget to set the value of "index.php" to "" in your config.
base_url is case sensitive
localhost/site/controller = c:...\site
localhost/SITE/controller = c:...\SITE
make sure you are not missing .htaccess file in your root directory. Or check for its accuracy. Make sure uri_protocol and base_url are set correctly in config.php.
for sample, i am copying my .htaccess file here
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /your_dir
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
I used this to get rid of index.php in url.
I had a similar problem when transferring a CI site from WAMPP to a LAMPP that someone else had made. It would seem that WAMPP was configured to be case-insensitive, as when I converted all my controller/model/view file names and all php strings containing controller/model/view names to lowercase it worked perfectly.

Resources