开发者

Where's the htaccess file in codeigniter?

开发者 https://www.devze.com 2023-01-11 02:21 出处:网络
I\'m wondering how CodeIgniter rewrites the url. By default, there is no htaccess file, yet it still works?开发者_高级运维

I'm wondering how CodeIgniter rewrites the url. By default, there is no htaccess file, yet it still works?开发者_高级运维

thanks


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消