EllisLab text mark
Advanced Search
     
routing problem
Posted: 09 February 2012 09:32 AM   [ Ignore ]
Joined: 2012-02-09
2 posts

Hello together.
the roouting doesn’t seam to work, or I’ve configured the wrong way.

I have a root folder: www.mysite.com/cm13 and have set this in the config.php

$config['base_url''http://www.mysite.com/cm13/';
...
$config['uri_protocol'"REQUEST_URI"

In the routes.php file I’ve set the following:

$route['default_controller'"welcome";
$route['404_override''';
$route["users""users";

//For pages those have a static name
$route['{default_controller}/{default_method}/about.html'"{original_controller}/{original_method}";

//rule to rout request with number values
$route['{default_controller}/{default_method}/:num'"{original_controller}/{original_method}";

//rule to rout request with regular expression values
$route['{default_controller}/{default_method}/([a-z]+)-{delimiter}'"{original_controller}/{original_method}/$1"

My htaccess file hase the following code:

<IfModule mod_rewrite.c>

    
RewriteEngine On
    RewriteBase 
/cm13/

    
# Disable rewrite for valid directory/files
    
RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond 
%{REQUEST_FILENAME} !-

    
#map all request urls to a specific controller method
    
RewriteRule ^(.*)$ index.php?/{controller}/{method}/$1 [L]
</IfModule

The users controller:

class Users extends CI_Controller {
 
 
public function index()
 
{
       
echo "UsersIndex<br>";
 
}

but when I try to call http://www.mysite.com/cm13/users, I get an 404 error message.
What can I do? Or what have I done wrong?

 
Posted: 09 February 2012 10:38 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-19
6267 posts

You cannot do routing like that! Also your .htaccess file will not allow that!

CodeIgniter User Guide - URI Routing

 Signature 

Ceritfied State of CT Computer Programming Teacher.
Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

 
Posted: 09 February 2012 12:34 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2012-02-09
2 posts

I already viewed the URI Routing page. But don’t understand why it doesn’t work, and what ist required so that it works.

 
Posted: 09 February 2012 02:52 PM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2009-02-19
3800 posts

Using {var} isn’t a regular expression.  Use the real controller/method names or use regular expressions in your routing rules.

Same in your .htaccess.  .htaccess gets processed the very first thing on each request, before CI gets the request.  How is it supposed to know what {controller} and {method} are?

Routes can either be specified using wildcards or Regular Expressions

 Signature