codeigniter 中的 htaccess 文件在哪里?

发布于 2024-09-14 13:40:04 字数 70 浏览 2 评论 0原文

我想知道 CodeIgniter 如何重写 url。默认情况下,还没有htaccess文件 它还有效吗?

谢谢

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

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

相对绾红妆 2024-09-21 13:40:04

已经有一段时间了,但万一您不知道 .htaccess 是一个隐藏文件,它位于您的根文件夹中......
希望有帮助

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

往日 2024-09-21 13:40:04

一切都通过index.php 路由。即

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

您可以使用 htaccess 文件删除 URL 的“index.php”部分。即

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

这将为您提供“更漂亮”的 URL,即

  site.com/controller/method/arg

但是,这对于 CI 正确路由 URL 来说并不是必需的。根据您的 apache 配置,这通常仍会正确解析,并将请求移交给 index.php,而后者又确定“路径”为 /controller/method/arg。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文