Route problem

#1
[eluser]Unknown[/eluser]
Greetings,

I'm rebuilding my site because of its unreadablity. Unfortunately I have a problem with routes or redirection.
At first my url was :

Code:
mysite.com/en/class/function/id

All codes were in a file in controllers directory. After some time, I understood that I wouldn't be able to remember which class had which function even though I wrote function names good.

So I decided to change class name with a folder and create file for each function.
When its like
Code:
mysite.com/en/folder/class/

There is no problem. But when an ID appears in url, it goes 404 like :

Code:
mysite.com/en/folder/class/id

I'm using index function for class call but still whenever I use id, it goes 404

Here is my .htaccess and some of my config file
Code:
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['enable_query_strings'] = FALSE;

$route['default_controller'] = "main";
$route['404_override'] = '';
$route['^(tr|en)/(.+)$'] = "$2";
$route['^(tr|en)$'] = $route['default_controller'];  
----------------------------------------------------
<IfModule mod_rewrite.c>

    RewriteEngine On
    RewriteBase /

    RewriteRule ^(.*)/index/?$ $1 [L,R=301]

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

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

</IfModule>

<IfModule !mod_rewrite.c>

    # Without mod_rewrite, route 404's to the front controller
    ErrorDocument 404 /index.php

</IfModule>

#2
[eluser]Stefan Hueg[/eluser]
Hi,
I may be wrong, but what you're trying to do is to call a function with the name of your "id" inside of your class.

Creating a controller for each function is not advisable. You should put all functions that are directly related to a controller in the specific one, like "/news/add", "/news/delete" etc. Try to stick to the basic CRUD functions and extend your controllers accordingly.

If you need custom routes or URLs you could re-route them.

#3
[eluser]Unknown[/eluser]
Looks like it's not a good idea to do it my way.
I'll have to find another method or leave it as it is.

Thanks for reply!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.