CodeIgniter Forums
mapping routes - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: mapping routes (/showthread.php?tid=11797)



mapping routes - El Forum - 09-23-2008

[eluser]paulcj2[/eluser]
my application allows many sites to work off the same database. the url for a specific site includes the site name as the second segment. Here is a sample url:
http://www.elsakfiberarts.com/page/elsakfiberarts/342
Which represents:
http://www.sitedomainname.com/function/sitename/page_id

I have looked at the tutorial on remapping the urls this way via the routes file,
http://ellislab.com/codeigniter/user-guide/general/routing.html
but don't see an example that applies. Please advise.


mapping routes - El Forum - 09-24-2008

[eluser]paulcj2[/eluser]
I tried
Code:
$route['page/([a-z]+)/(:num)'] = "page/index/$1/$2";
,
and the url
Code:
http://clickbasicsdemo.com/page/clickbasicsdemo/437
but it does not work on controller:
Code:
class Page extends Controller {

    function index($site_address, $art_id)
    {
        echo '<p>Site address: '.$site_address.'</p>';
        echo '<p>Article id: '.$art_id.'</p>';
    } //function
    
} //class
This url, however, does work:
Code:
http://localhost/clickbasicsdemo/index.php/page/clickbasicsdemo/437
How can I get it to work without index.php in the url?


mapping routes - El Forum - 09-24-2008

[eluser]paulcj2[/eluser]
I found:
http://ellislab.com/codeigniter/user-guide/general/urls.html
and tried adding to my .htaccess file
Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
However, that generated a 500 Server error.

I checked the apache/cong/httpd.conf file and it is set to allow all in the .htaccess file
Code:
AllowOverride All



mapping routes - El Forum - 09-24-2008

[eluser]paulcj2[/eluser]
Everything works fine on my production server. Somehow the .htaccess file still throws a 500 error on my XAMPP development server. Hmmmmmm.


mapping routes - El Forum - 09-24-2008

[eluser]paulcj2[/eluser]
I changed my .htaccess file on my development server to:
Code:
RewriteRule ^(.*)$ http://localhost/clickbasicsdemo/index.php/$1 [L]
and now the links work there too. I'm done.


mapping routes - El Forum - 09-24-2008

[eluser]metaltapimenye[/eluser]
gee.. u left me no space to put some words uh?.. Big Grin


mapping routes - El Forum - 09-25-2008

[eluser]paulcj2[/eluser]
Thanks for checking in, anyway.