6

I have installed CI in subdirecotry www.siteb.com/rexona

My .htaccess inside www.siteb.com/rexona :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /rexona

#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]

#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
#Submitted by Michael Radlmaier (mradlmaier)
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>

ErrorDocument 404 /index.php
</IfModule>

In config.php:

$config['index_page'] = '';
$config['base_url'] = '';
$config['uri_protocol'] = 'AUTO';

Whenever I try access controllers I get No input file specified. However it does load default controller, but I cant access any methods in default controller either.

Any thoughts? Thanks.

bukowski
  • 1,893
  • 7
  • 34
  • 54

4 Answers4

24

Your uri_protocol needs to be set to something - at least set it to auto.

The error you are getting is because PHP runs as CGI which means you need to pass the URL rewrite to index.php?/$1 instead (note the question mark).

Repox
  • 15,015
  • 8
  • 54
  • 79
  • will this still work if I'd move code to a server where PHP runs as apache module? – Draex_ Nov 25 '12 at 15:50
  • @Peter If the `uri_protocol`configuration is set to AUTO, I would suspect it does. Though, I would not recommend using server settings specific for one type of implementation when the server uses another. – Repox Nov 25 '12 at 15:54
  • thanks, it works on live hosting and also error error related to unable load dynamic library is disappeared – Rizwan Ranjha May 24 '15 at 09:47
  • @Repox please tell More about this. I am curious and I can't find anywhere answer for this question, Why do we actually need here this question mark after index.php? And what does it do? How does it work? I had project where I hadn't this question mark and it worked. And now I got other project, and it doesn't work with it. What is this all about? – Krystian Polska Sep 09 '17 at 20:51
  • @KrystianPolska The question mark is a part of the URI; it enabled CodeIgniter to route based on the input in the `$_SERVER['QUERY_STRING']`or `$_SERVER['REQUEST_URI']` the variable. Some applications have a different approach, which probably is the case in your situation. – Repox Sep 09 '17 at 21:48
4

Godaddy hosting, it seems fixed on.htaccess, myself it is working by changing:

RewriteRule ^(.*)$ index.php/$1 [L]

to

RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Enamul Hassan
  • 5,266
  • 23
  • 39
  • 56
Suresh Sekar
  • 928
  • 6
  • 7
1

Your $config['uri_protocol'] should not be empty. The default is AUTO, passing in an empty string will break the core URI class, which is used to route your requests through the Router class.

/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of 'AUTO' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'AUTO'            Default - auto detects
| 'PATH_INFO'       Uses the PATH_INFO
| 'QUERY_STRING'    Uses the QUERY_STRING
| 'REQUEST_URI'     Uses the REQUEST_URI
| 'ORIG_PATH_INFO'  Uses the ORIG_PATH_INFO
|
*/
$config['uri_protocol'] = 'AUTO';

As the comments say: "If your links do not seem to work, try one of the other delicious flavors".
Empty string is not one of those flavors, it would end up trying to read from $_SERVER[''], which is normally going to be empty.

Wesley Murch
  • 101,186
  • 37
  • 194
  • 228
  • Hi, I tried all options but with no success.... Where could be the problem? Is it .htaccess or CI configuration or server...? – bukowski Apr 28 '12 at 08:34
  • Thnks, left it on auto. For some reason I thought that leaving it blank would set it to default. – bukowski Apr 28 '12 at 10:03
  • From looking at CI's source code, I didn't see a reason why an empty string could not do the same job as "AUTO". I personally think it would make sense and be more consistent with other config items, it's just the way they chose to do it I guess. – Wesley Murch Apr 29 '12 at 00:55
0

I get the same error in hostinger free account, resolve with the issue presented by jhon foo above.

my .htaccess

RewriteBase /MY_SUBFOLDER_UNDER_HTML_DIRECTORY/
RewriteEngine on

RewriteBase /mY_subfolder/
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$0 [QSA,L]

This work fine, thanks a lot!

Adam Preble
  • 2,162
  • 17
  • 28