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

Hi 
I was looking the other threads related to this topic, but all changes does not making help to the outcome.

I got this error The requested URL /ESS/user/login was not found on this server

404 Error

Here is my .htaccess:


<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^asset.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Config.php

$config['base_url'] = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") ? "https" : "http");
$config['base_url'] .= "://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);

$route['default_controller'] = 'user';
Reply
#2

Try this one, you may need to remove the ? question mark from the index rules.

PHP Code:
<IfModule mod_rewrite.c>
 
   RewriteEngine On

    
# NOTICE: If you get a 404 play with combinations of the following commented out lines
 
   # AllowOverride All
 
   RewriteBase /

 
   # Make sure directory listing is disabled
 
   Options +FollowSymLinks -Indexes

    RewriteCond 
%{REQUEST_URI} ^system.*
 
   RewriteRule ^(.*)$ /index.php?/$[L]

 
   RewriteCond %{REQUEST_URI} ^application.*
 
   RewriteRule ^(.*)$ /index.php?/$[L]

 
   RewriteCond %{REQUEST_URI} ^asset.*
 
   RewriteRule ^(.*)$ /index.php?/$[L]

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

Also you may need to try different settings in ./application/config/config.php


For this:
PHP Code:
/*
|--------------------------------------------------------------------------
| URI PROTOCOL
|--------------------------------------------------------------------------
|
| This item determines which server global should be used to retrieve the
| URI string.  The default setting of 'REQUEST_URI' works for most servers.
| If your links do not seem to work, try one of the other delicious flavors:
|
| 'REQUEST_URI'    Uses $_SERVER['REQUEST_URI']
| 'QUERY_STRING'   Uses $_SERVER['QUERY_STRING']
| 'PATH_INFO'      Uses $_SERVER['PATH_INFO']
|
| WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
*/
$config['uri_protocol']    = 'REQUEST_URI'

Make sure you also set your base url.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(11-08-2018, 06:57 AM)dsubhankar Wrote: Here is my .htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_URI} ^asset.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

The following items should be removed.

Code:
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_URI} ^asset.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

In the case of the system and application, no http request to these folders should be allowed. In fact, as it is shipped, CodeIgniter includes .htaccess files that deny access to those folders and their subfolders. So, those conditions and rules are superfluous and therefore a waste of server resources.

In the case of the asset folder which I assume has things like CSS, JS, and image files you don't want index.php as part of the request.

A typical request for a stylesheet looks like this.

Code:
<link rel="stylesheet" href="https://example.com/assets/css/example.css">

But (unless I'm terribly mistaken) the rewrite you use would result in

Code:
<link rel="stylesheet" href="https://example.com/index.php/assets/css/example.css">

And that's going to fail miserably producing a "404 not found" for the resource.

I also suggest removing the tags <IfModule mod_rewrite.c> </IfModule>.

Yes, you see them used all the time in online examples. But the Apache documentation on <IfModule> has this to say about <IfModule>

Quote:It should not be used to enclose directives that you want to work all the time, because it can suppress useful error messages about missing modules.

It's not critical they be removed, but if you are relying on rewrite working it's probably good to have an error show up in the server logs.

I'm not sure any of those changes will fix the problem though. But they should still be done.

InsiteFX's suggestion of changing

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

to

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

Is a good idea.

I have to ask though, have you followed all the CodeIgniter's rules for file and class naming?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB