Welcome Guest, Not a member yet? Register   Sign In
CI not called when using mod_rewrite with PHP5 running as cgi
#11

[eluser]Sarfaraz Momin[/eluser]
can you try this .htaccess rule and let me know the results.

Code:
RewriteCond $1 !^(index\.php|images|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?$1 [L]

This code is to skip the index.php from your urls. once you do this try to access pages/aboutus.
#12

[eluser]david_ais[/eluser]
[quote author="Sarfaraz Momin" date="1194383258"]can you try this .htaccess rule and let me know the results.

Code:
RewriteCond $1 !^(index\.php|images|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
[/quote]
With a minor edit - /index.php/$1 instead of /index.php?$1 - it did what you'd expect under PHP4 but returned "No input file specified." under PHP5 - which is the problem I'm trying to fix.

Regards

db
#13

[eluser]Sarfaraz Momin[/eluser]
You know what? The error “No input file specified” is actually a CI error and I got it when I started using CI for the first time. Try these settings in the config.php under application/config folder.

Code:
$config[’index_page’] = “index.php”;
$config[’uri_protocol’] = “QUERY_STRING”;

and .htaccess should be

Code:
RewriteCond $1 !^(index\.php|images|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?$1 [L]

Please try this and let me know.
#14

[eluser]david_ais[/eluser]
[quote author="Sarfaraz Momin" date="1194386553"]You know what? The error “No input file specified” is actually a CI error.[/quote]

Thanks for the suggestion but it's focussing in the wrong place.

Although it might perhaps be a CI error - this particular instance is not being generated by CI. This error message is also generated by the cgi processor when it's passed a URI to process that doesn't exist. When the error I've encountered occurs - CI isn't running at all.

I tested this by adding a line to index.php so that the first thing it did was write an entry to the server error log. When the site was running under PHP4 - the message was written every time. But under PHP5 - no message was written. Nor was anything logged in CI's own log.

Whatever is causing the problem - it's happening before CI runs. So there's nothing to be gained by experimenting with different CI configurations.


Regards

db
#15

[eluser]Holger Lampe[/eluser]
I had the same problem some time ago.

If you have access to the php.ini, look for:
Quote:; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix it's paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is zero. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
cgi.fix_pathinfo = 0

and set the value to zero, it helped in my case.
#16

[eluser]david_ais[/eluser]
[quote author="Holger Lampe" date="1194390752"]If you have access to the php.ini, look for:
Quote:; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.
; ...

cgi.fix_pathinfo = 0

and set the value to zero, it helped in my case.[/quote]

I don't have access to php.ini - although I do have access to a method of over-riding some settings. But according to phpinfo cgi.fix_pathinfo is already set to 0.

Regards

db
#17

[eluser]Sarfaraz Momin[/eluser]
I suppose the best bet to run your site right now with PHP 5 will be with index.php in your routed URLs. Since this URLs work behind the scene the users would just see clean URLs and the site would run fine. What I mean is to use the example that I mentioned earlier.

Code:
$route['aboutus\.html'] = "index.php/pages/aboutus";

In this example the user will only see www.domain.com/aboutus.html and it would be internally rerouted to index.php/pages/aboutus which is fine. The only drawback is that you will have to write a rule for every single page URL on your site.

I hope it makes sense.

Good Day !!!
#18

[eluser]david_ais[/eluser]
I've finally got to the bottom of this. As suspected it was a server configuration issue at the ISP.

It turns out that when running PHP5 and following an internal redirect via mod_rewrite, their server is not configured to handle a URL in the form /script.php/parameter but it is able to handle it if the URL is in the form script.pgp?parameter - even though both versions of the URL would work if typed directly into the browser.

So in fact Sarfaraz Momin's last suggestion was in the right direction - though till the ISP came clean about their server I'd probably have still struggled to get there. The ISP kept insisting on blaming CI instead of looking at the available evidence!


The solution came down to changing:

Code:
RewriteRule ^(.+)\.html$ /index.php/$1 [L]
  to
RewriteRule ^(.+)\.html$ /index.php?$1 [L]
And switching $config['uri_protocol'] from REQUEST_URI to QUERY_STRING or AUTO

Replacing most of the mod_rewrites with entries in routes does tidy things up and I'll definitely do that. But it doesn't eliminate the problem as there'll still be that one RewriteRule to map out index.php from the URL that would still trigger the problem.

So - problem solved. Thanks for everyone's input on this.


Regards

db
#19

[eluser]mouras[/eluser]
I had the same problem on my DREAMHOST installation. When, following the CI User Guide on how to remove index.php from the calling URL added a .htacces file, I was no longer able to access the welcome page. Instead I got an empty page reading 'No input file specified'.

None of the various suggestions found on this thread was able to correct the problem, but after some testing I finally found a solution. I only changed the .htaccess file and kept the default settings in config.php. I set the .htaccess as follows:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|my_include_directory|robots\.txt|favicon\.ico|sitemap\.xml)
RewriteRule ^(.*)$ /index.php?$1 [L]

I hope this will help others.
#20

[eluser]ImageSmith[/eluser]
@db
Thanks for the post on your fix. I am hosting with Hosting Shop in Aust and some of their servers are now running php5 from CGI. I guess this will become the norm as time goes by and php 4 servers begin to phase out.
@mouras
Your fix works for my server only if the config url_suffix is set to empty. Adding a suffix will cause a CI 404 error.

cheers for the posts peeps.




Theme © iAndrew 2016 - Forum software by © MyBB