URI Routing for URLs with dashes (-)

#1
[eluser]ehicks727[/eluser]
I'm converting an existing project to CI and I'm stuck on an important issue. The existing project has urls with dashes, and this has to stay this way for SEO purposes.

I searched the forum and didn't find an answer that solved my problem.

Here's what I've done so far, maybe someone will notice right away what I'm doing wrong, hopefully?

My goal is to route to a url like this: http://www.example.com/business-directory.php

I created a controller business_directory.php with the following code so far.

Code:
class Business_directory extends Controller {

    function __construct() {
        parent::Controller();    
    }
    
    function index() {
        echo 'Hello World!';
    }
    
}

It works if I don't use routing and just go to http://www.example.com/business_directory I see 'Hello World!"

I added this to my routes.php:

Code:
$route['business-directory'] = "business_directory";


I'm getting 404s when I type in http://www.example.com/business-directory

Ideally, I'd like to add
Code:
$config['url_suffix'] = ".php";
to my config.php file so that I can type in http://www.example.com/business-directory.php

I hope that makes sense, and I GREATLY appreciate any help that anyone can give me.

thanks,
Eric

#2
[eluser]ehicks727[/eluser]
Ok, I'm retarded. In the Controllers guide, I read that this default constructor works in PHP5, so I used it.

Code:
function __construct() {
        parent::Controller();    
    }

Then I noticed that routing stopped working completely. So I changed my default constructor to this again

Code:
function Business_directory() {
        parent::Controller();    
    }

and now everything works great. Why does this
Code:
__construct()
break routing??


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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