Welcome Guest, Not a member yet? Register   Sign In
Routing issue
#1

[eluser]garycooper[/eluser]
Hi Everyone,

First message here, so first thanks in advance for your welcome Smile

I watch and install the source file of shawn videocast (Shawn VideoCast)

I edit all config files to make it work on my local pc (config,virtual host, host)

When i try the url http://dev.website.local/ i'm redirect to the default controller that's good.

But when i try to reach other controller (login, dashboard) i get 404 error.

And my 404 error are not displayed with CI 404 template but default browser.

I think i've got a routing issue but after 4 hours research i can't find where....

here is my routes.php

Code:
$route['default_controller'] = "main";
$route['scaffolding_trigger'] = "";
$route['login'] = "main/login";
$route['logout'] = "main/logout";

thanks a lot for your help
#2

[eluser]danmontgomery[/eluser]
If you're getting the apache 404 it means the request is never reaching CI. Something awry with your htaccess, are you using one? Are you including index.php in your url?
#3

[eluser]garycooper[/eluser]
here is htaccess file
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>

u talk about .htaccess file from default CI directory ?
#4

[eluser]garycooper[/eluser]
when i try http://dev.website.local/index.php/login it works

but when i try http://dev.website.local/login i get apache 404...weird
#5

[eluser]danmontgomery[/eluser]
Is there a reason you have nothing after RewriteBase? If your index.php is in webroot you should leave that value as / or remove it completely. There's also really no reason to be mixing rewritebase with absolute paths in your rewriterules (I realize this is something that comes from the wiki)

You can also try removing the ? after index.php.

Have you looked at apache's error log?
#6

[eluser]garycooper[/eluser]
Code:
[Mon Sep 13 11:21:22 2010] [error] [client 127.0.0.1] File does not exist: C:/LocalPagesDirect/admin.test.yyy.com/codeigniter/login
here is apache error

Honestly i'm not very good with .htaccess

I first used shawn ones
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|resources)
RewriteRule ^(.*)$ /index.php/$1 [L]

but i get internal server error on apache so i found the first one on forum Smile

Do you have a good .htaccess to recommend me ?

thanks
#7

[eluser]garycooper[/eluser]
Finally the original htaccess was good
i just add to uncomment this line on http.conf

LoadModule rewrite_module modules/mod_rewrite.so


problem solved
#8

[eluser]Nalorin[/eluser]
Quote:i just add to uncomment this line on http.conf

LoadModule rewrite_module modules/mod_rewrite.so


problem solved

It's odd that removing the mod_rewrite module would fix a problem with rewriting not happening properly.

Quote:when i try http://dev.website.local/index.php/login it works

but when i try http://dev.website.local/login i get apache 404…weird

Since the first line works, your codeigniter is working properly. The second one not working means that you don't have the proper rewrite rules (see noctrum's suggestions above - the ? should not be there unless you're using $config['uri_protocol'] = "QUERY_STRING";

If the second line is not working properly, try the uri_protocol "REQUEST_URI", and each of the others, to see if one of them works.

Also, check to ensure that in config.php
Code:
$config['index_page'] = "";

Give those things a shot and see if it makes your URLs much nicer Wink




Theme © iAndrew 2016 - Forum software by © MyBB