Welcome Guest, Not a member yet? Register   Sign In
Requested URL was not found on this server
#1

[eluser]1cookie[/eluser]
hi

I'm having trouble with a simple script. My setup is: Apache and Ubuntu. I'm using mod_rewrite on my localhost. My .htaccess file looks like:

Code:
<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>
and is placed under my CodeIgniter directory. My controller:

Code:
&lt;?php

class Hello extends Controller {

        function __construct() {
                parent::Controller();

        }

        function you() {
                $this->load->view('my_view');
        }


}
/* End of file hello.php */
/* Location: ./system/application/controllers/hello.php */

My view:

Code:
&lt;?php

echo 'hello';

/* End of file my_view.php */
/* Location: ./system/application/views/my_view.php */

Nice and simple, but I can't display the page.

Code:
Not Found

The requested URL /CodeIgniter/Hello was not found on this server.
Apache/2.2.14 (Ubuntu) Server at localhost Port 80

I've checked all the usual suspects:

error.log displays:

Code:
Sun Sep 12 17:29:31 2010] [error] [client 127.0.0.1] File does not exist: /var/www/CodeIgniter/Hello
[Sun Sep 12 17:29:32 2010] [error] [client 127.0.0.1] File does not exist: /var/www/CodeIgniter/Hello
[Sun Sep 12 17:42:27 2010] [error] [client 127.0.0.1] File does not exist: /var/www/CodeIgniter/Hello

Code:
$config['base_url']    = "http://localhost/";

but no joy!

help
#2

[eluser]InsiteFX[/eluser]
I would take a look at your base_url and
directory structure.

Also check your index.php file and make sure
it is aetup for the right paths to the system
and application folders.

InsiteFX
#3

[eluser]1cookie[/eluser]
hi

[quote author="InsiteFX" date="1284340053"]I would take a look at your base_url.
[/quote]

With base_url set to:

Code:
$config['base_url']    = "http://localhost/";
even
Code:
$config['base_url']    = "http://example.com/";

and with routes.php, set to:

Code:
$route['default_controller'] = "welcome";

upon visiting:
Code:
http://localhost/CodeIgniter/
, the (default) welcome_message.php page loads successfully!


Quote:and
directory structure.

Directory structure looks like <a href="http://webtechnologies.me.uk/img/dirStrcture.png">this</a>. I can't see any immediate problems here?

Quote:Also check your index.php file and make sure
it is aetup for the right paths to the system
and application folders.

InsiteFX

After checking 'http://ellislab.com/codeigniter/user-guide/general/managing_apps.html', I don't think any of this applies to me? I mean, I'm not:

> Renaming my Application Folder
> Relocating my Application Folder
> Running Multiple Applications with one CodeIgniter Installation

It's simply a clean default install for all intents and purposes. However, my index.php is:
Code:
&lt;?php
/*
|---------------------------------------------------------------
| PHP ERROR REPORTING LEVEL
|---------------------------------------------------------------
|
| By default CI runs with error reporting set to ALL.  For security
| reasons you are encouraged to change this when your site goes live.
| For more info visit:  http://www.php.net/error_reporting
|
*/
    error_reporting(E_ALL);

/*
|---------------------------------------------------------------
| SYSTEM FOLDER NAME
|---------------------------------------------------------------
|
| This variable must contain the name of your "system" folder.
| Include the path if the folder is not in the same  directory
| as this file.
|
| NO TRAILING SLASH!
|
*/
    $system_folder = "system";

/*
|---------------------------------------------------------------
| APPLICATION FOLDER NAME
|---------------------------------------------------------------
|
| If you want this front controller to use a different "application"
| folder then the default one you can set its name here. The folder
| can also be renamed or relocated anywhere on your server.
| For more info please see the user guide:
| http://ellislab.com/codeigniter/user-guide/general/managing_apps.html
|
|
| NO TRAILING SLASH!
|
*/
    $application_folder = "application";

/*
|===============================================================
| END OF USER CONFIGURABLE SETTINGS
|===============================================================
*/


/*
|---------------------------------------------------------------
| SET THE SERVER PATH
|---------------------------------------------------------------
|
| Let's attempt to determine the full-server path to the "system"
| folder in order to reduce the possibility of path problems.
| Note: We only attempt this if the user hasn't specified a
| full server path.
|
*/
if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder);
}

/*
|---------------------------------------------------------------
| DEFINE APPLICATION CONSTANTS
|---------------------------------------------------------------
|
| EXT        - The file extension.  Typically ".php"
| SELF        - The name of THIS file (typically "index.php")
| FCPATH    - The full server path to THIS file
| BASEPATH    - The full server path to the "system" folder
| APPPATH    - The full server path to the "application" folder
|
*/
define('EXT', '.php');
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('FCPATH', str_replace(SELF, '', __FILE__));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}

/*
|---------------------------------------------------------------
| LOAD THE FRONT CONTROLLER
|---------------------------------------------------------------
|
| And away we go...
|
*/
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

/* End of file index.php */
/* Location: ./index.php */


Smile
#4

[eluser]WanWizard[/eluser]
Assuming you have installed CI in the folder 'CodeIgniter' of your webserver docroot, and your .htaccess is placed in this folder (and not in the docroot), you will need
Code:
RewriteBase /CodeIgniter
in your .htaccess.
#5

[eluser]1cookie[/eluser]
hi

[quote author="WanWizard" date="1284391498"]Assuming you have installed CI in the folder 'CodeIgniter' of your webserver docroot[/quote]

It is!

Quote: and your .htaccess is placed in this folder (and not in the docroot)

It is. See <a href="http://webtechnologies.me.uk/img/dirStrcture.png" target="_black">screen shot</a>


Quote: you will need
Code:
RewriteBase /CodeIgniter
in your .htaccess.
Upon making these changes, and entering
Code:
http://localhost/CodeIgniter/Hello/you
into the borwser, i get
Code:
The requested URL /CodeIgniter/Hello/you was not found on this server.

I don't usually have any problems with a clean install?

Smile
#6

[eluser]pickupman[/eluser]
Have you tried /CodeIgniter/hello/you ? Controllers have lowercase uri's but are capitalized only in their declaration.

Try changing in your .htaccess
Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

to
Code:
RewriteRule ^(.*)$ index.php/$1 [L]
#7

[eluser]1cookie[/eluser]
hi, and thanks for the tips everyone!

[quote author="pickupman" date="1284400617"]Have you tried /CodeIgniter/hello/you ? Controllers have lowercase uri's but are capitalized only in their declaration.[/quote]

Yes, have tried:
Code:
http://localhost/CodeIgniter/hello/you
http://localhost/CodeIgniter/Hello/you

but still, 404 Not Found.


Quote:Try changing in your .htaccess
Code:
RewriteRule ^(.*)$ index.php?/$1 [L]

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

Made those changes (and restarted Apache), but no joy! Really puzzles me this..

Smile
#8

[eluser]pickupman[/eluser]
Don't forget since you are on linux, filenames are case sensitive. Do you have application/controllers/Hello.php or /application/controllers/hello.php? The latter is what you would want.

Also, are you getting an apache 404 or a CI 404 error?
#9

[eluser]1cookie[/eluser]
hi

[quote author="pickupman" date="1284401967"]Don't forget since you are on linux, filenames are case sensitive. Do you have application/controllers/Hello.php or /application/controllers/hello.php? The latter is what you would want.
[/quote]
Full path is:

Code:
var/www/CodeIgniter/system/application/controllers/hello.php

so the file is named 'hello.php', lower-case.


Quote:Also, are you getting an apache 404 or a CI 404 error?

It's an Apache 404

Code:
Not Found

The requested URL /CodeIgniter/hello/you was not found on this server.
Apache/2.2.14 (Ubuntu) Server at localhost Port 80


Smile
#10

[eluser]pickupman[/eluser]
Have you allowed .htaccess files in your apache config? Not in ubuntu right now, but I believe it's /etc/apache2/conf/httpd.conf (or site-default).

You need to have
Code:
AllowOverride All
By default this will be set to None.


The apache error means it's not getting to CI. CI has it's own 404 error. Out of curiosity what happens if you remove the leading / from /index.php in your .htaccess? Or better yet, try using just this in .htaccess
Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]




Theme © iAndrew 2016 - Forum software by © MyBB