Welcome Guest, Not a member yet? Register   Sign In
Newb Installation Question
#1

[eluser]DanJ.[/eluser]
New to CodeIgnitor, just trying to get it installed and the basics functioning. I'm running Apache2 on Debian Linux. The root of my website is located at /var/www, as is standard under Debian. I run a number of things on my server, so I don't want CodeIgnitor installed in the root. My intent is to use CI to create a special purpose book database, so I created a directory /var/www/books/ and placed CI there. Under /var/www/books, I have the index.php file, the license.txt file and the system and user_guide sub-directories. I edited config.php, setting the base_url to "http://www.mydomain.org/books/". Opening a browser to http://www.mydomain.org/books/, I see the Welcome to CodeIgnitor page, so everything looks good.

Next, I tried to follow the "Hello World" video tutorial. I created /var/www/books/system/application/controllers/library.php:

<?php
class Library extends Controller {
function index()
{
echo 'Hello World';
}
}
?>

Browsing to http://www.mydomain.org/books/index.php/library (with or without a trailing slash), I get "The URI you submitted has disallowed characters." Browsing to http://www.mydomain.org/books/library, I get an Apache 404 error. It's definitely the Apache 404 page and not a CI provided 404 page. This is with or without a trailing slash, with or without the .htaccess file as described in the User Guide. The User Guild doesn't make the location of the file clear, so I placed the .htaccess file under the CI root, /var/www/books/.

If I turn on query strings, then http://www.mydomain.org/books/index.php?c=library gives me the "Hello World" page.

Preferably, I'd like to get the .htaccess file working, eliminating the index.php in the URL.

Attempting to use index.php in the URL, however, I don't understand why I'm getting a disallowed character error. Browsing to
http://www.mydomain.org/books/index.php works, browsing to http://www.mydomain.org/books/index.php/library gives the error. I seriously hope that none of the letters in the word "library" are disallowed. :-) I'm probably missing something quite simple but I've been digging through the User Guide and Googling the issue but without any success. Any assistance in helping me get started would be greatly appreciated.
#2

[eluser]WanWizard[/eluser]
First, remove any .htaccess, and see what happens. If http://www.mydomain.org/books/index.php and http://www.mydomain.org/books/index.php/welcome work, so should http://www.mydomain.org/books/index.php/library.

If it works, post your .htaccess, I think it's a problem with your rewrite rules.
#3

[eluser]DanJ.[/eluser]
[quote author="WanWizard" date="1290635143"]First, remove any .htaccess, and see what happens. If http://www.mydomain.org/books/index.php and http://www.mydomain.org/books/index.php/welcome work, so should http://www.mydomain.org/books/index.php/library.

If it works, post your .htaccess, I think it's a problem with your rewrite rules.[/quote]

Removing the .htaccess file, http://www.mydomain.org/books/index.php gives me the Welcome page. It works either with or without a trailing slash. http://www.mydomain.org/books/index.php/welcome (with or without a trailing slash) gives me:


An Error Was Encountered

The URI you submitted has disallowed characters.
#4

[eluser]DanJ.[/eluser]
More funkiness that may give someone a clue as to what's happening. If I enable query strings, then both:

http://www.mydomain.org/books/index.php/library

and

http://www.mydomain.org/books/index.php/welcome

work correctly. If I turn off Query Strings, I get the disallowed character error. I believe query strings should only be required to allow the ?c=library format, right? It should not be required for the format listed above.
#5

[eluser]pickupman[/eluser]
Have you changed anything for uri characters in application/config/config.php? If you unzipped the files from your account into /var/www/books, have you changed file permissions on the files? You may have to chown -R wheel the files to be accessible to apache group. Or may also apply if you created the the library controller. Make sure you have the correct rights on that file.
#6

[eluser]WanWizard[/eluser]
Are you testing on a host that runs PHP in CGI mode?
#7

[eluser]DanJ.[/eluser]
[quote author="pickupman" date="1290639739"]Have you changed anything for uri characters in application/config/config.php? If you unzipped the files from your account into /var/www/books, have you changed file permissions on the files? You may have to chown -R wheel the files to be accessible to apache group. Or may also apply if you created the the library controller. Make sure you have the correct rights on that file.[/quote]

I haven't touched the URI characters. Apache is run in the www-data group. I did the chmod after unzipping the file and all files have the correct perms.

I'm far from a PHP expert but I'm conversant in Perl and C, so I can usually muddle through with PHP. (I expect to get better in PHP once I get this working and start programming my project.) I modified the preg_match() in function_filter_uri() in URI.php as follows:

$matchval = "|^[".preg_quote($this->config->item('permitted_uri_chars'))."]+$|i";
if ( ! preg_match($matchval, $str))
{
log_message('debug', "matchval = ".$matchval);
log_message('debug', "str = ".$str);
header('HTTP/1.1 400 Bad Request');
show_error('The URI you submitted has disallowed characters.');
}

My log shows the following:

DEBUG - 2010-11-24 12:48:01 --> Config Class Initialized
DEBUG - 2010-11-24 12:48:01 --> Hooks Class Initialized
DEBUG - 2010-11-24 12:48:01 --> URI Class Initialized
DEBUG - 2010-11-24 12:48:01 --> matchval = |^[a\-z 0\-9~%\.\:_\\\-]+$|i
DEBUG - 2010-11-24 12:48:01 --> str = library

The fact that the debug messages are being added to the log indicates the match is failing, but I can't see any reason why it should fail.
#8

[eluser]DanJ.[/eluser]
[quote author="WanWizard" date="1290642497"]Are you testing on a host that runs PHP in CGI mode?[/quote]

Apache has the php5.conf and php5.load mods enabled, so I'm reasonably sure it's not running in CGI mode.
#9

[eluser]DanJ.[/eluser]
OK, here's what's going on:

DEBUG - 2010-11-24 12:48:01—> matchval = |^[a\-z 0\-9~%\.\:_\\\-]+$|i

The match pattern is:

^[a\-z 0\-9~%\.\:_\\\-]+$

Note that the dashes in the character ranges a-z and 0-9 are escaped. If I remove the call to config->item('permitted_uri_chars') and manually set the match pattern to:

|^[a-z 0-9~%.:_\-]+$|i

with no escapes, the Hello World page loads correctly. I've checked config.php:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

There are no escapes on the dashes in the character ranges in config.php. So it appears to be being modified somewhere. I haven't tracked down where yet. This appears to be a bug in CI (or possibly PHP.) It seems like a bug of this nature would be affecting a lot of people but I haven't found anyone else complaining.




Theme © iAndrew 2016 - Forum software by © MyBB