CodeIgniter Forums

Full Version: mapping routes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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-gui...uting.html
but don't see an example that applies. Please advise.

El Forum

[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?

El Forum

[eluser]paulcj2[/eluser]
I found:
http://ellislab.com/codeigniter/user-gui.../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

El Forum

[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.

El Forum

[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.

El Forum

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

El Forum

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