views:

13

answers:

2

I'm wondering how CodeIgniter rewrites the url. By default, there is no htaccess file, yet it still works?

thanks

A: 

It's been some time but in case you don't know .htaccess is a hidden file and it lies on your root folder... hope that helps

rabidmachine9
A: 

Everything is routed through index.php. i.e.

  site.com/index.php/controller/method/arg

You'd use an htaccess file to remove the "index.php" slice of the URL. i.e.

RewriteCond %{REQUEST_URI} !^(/index\.php|/assets|/tmp|/robots\.txt|/crossdomain\.xml|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

Which would give you "prettier" URLs, i.e.

  site.com/controller/method/arg

But, this is not necessary for CI to route URLs correctly. Depending on your apache conf, this typically will still resolve correctly, and handoff the request to index.php, which in turn determines the "path" to be /controller/method/arg.

Matt