Welcome Guest, Not a member yet? Register   Sign In
Problem with Routes
#15

[eluser]dootzky[/eluser]
hi again guys :wow:

ok, I've got it working.
it's not nice, it's not pretty - but it DOES WORK! Smile

first - your last idea with .htaccess didn't help, I was still getting "404 error" for "old link" (/domino/article.php?aid=84)

and then I did this, this is my working solution:

.htaccess file
Code:
RewriteEngine on

#Old urls first
RewriteRule article\.php /domino/article/index/ [R=301,L]

# Now the index.php
RewriteCond $1 !^(index\.php|public|user_guide|robots\.txt)
RewriteRule ^(.*)$ /domino/index.php?/$1 [L]

my routes.php setting:
Code:
...
$route['article/(\d+)'] = "article/index/$1";
...

and finally, my article.php controller:
Code:
...
...

function index($id_article)
{
    // if we don't get $id_article the normal way, try to hack the redirected URL, and get the ID..
    // if even that fails -> show_404();
    if (!$id_article) {
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $fake_id = substr($url[4], 5, strlen($url[4]) - 5);
        
        if (is_numeric($fake_id)) $id_article= $fake_id;
        else show_404();
    }

    // do what you need to do here with your article..
}

...
...

so, for the normal page access, everything works. examples:
/domino/article/index/84 -> works
/domino/article/84 -> works
/domino/article/edit/84 -> works

and for the old "article.php" page attempt, this is what I get redirected to:
/domino/article.php?aid=84 => /domino/article/index/?aid=84

so - even if this is not "cool" solution, I somehow get to the "article" controller, and then I butcher the URL, and somehow I get the wanted ID. it will work for any ID length (84, 555, 1205, 44055 ..)

I really hope this will help someone else to get around the problems I've run to.
And of course, if someone here knows how do to this better - please do tell, I'll correct this solution then. Smile

And once again - I would like to say THANK YOU to both guys who've helped me out here, couldn't have done it without their help.

Cheers!
dootzky


Messages In This Thread
Problem with Routes - by El Forum - 09-05-2008, 12:03 AM
Problem with Routes - by El Forum - 09-05-2008, 01:04 AM
Problem with Routes - by El Forum - 09-05-2008, 01:18 AM
Problem with Routes - by El Forum - 09-05-2008, 01:31 AM
Problem with Routes - by El Forum - 09-05-2008, 01:32 AM
Problem with Routes - by El Forum - 09-15-2008, 01:11 PM
Problem with Routes - by El Forum - 09-15-2008, 01:22 PM
Problem with Routes - by El Forum - 09-15-2008, 01:24 PM
Problem with Routes - by El Forum - 09-15-2008, 03:52 PM
Problem with Routes - by El Forum - 09-15-2008, 03:58 PM
Problem with Routes - by El Forum - 09-15-2008, 04:05 PM
Problem with Routes - by El Forum - 09-16-2008, 08:05 AM
Problem with Routes - by El Forum - 09-16-2008, 08:22 AM
Problem with Routes - by El Forum - 09-16-2008, 02:25 PM
Problem with Routes - by El Forum - 09-16-2008, 03:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB