HTaccess 不重新路由 [CodeIgniter]
我有一个应用程序,在使用完整网址时效果很好:sitename.com/index.php/foo/,但是当我使用 HTaccess 删除 index.php 时,它似乎没有按预期工作。无论我访问哪个页面,我都只能看到主页。 htaccess 文件正在执行某些操作,因为如果没有该行,我会收到 404 错误。
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|file-manager-files|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
想法?
在我的测试站点上一切正常。这是需要调整的服务器设置吗?
I have an application that works great when using the full url: sitename.com/index.php/foo/ but when I use HTaccess to remove the index.php it doesn't seem to work as expected. No matter which page I access I only see the home page. The htaccess file is doing something because without that line I get a 404 error.
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|file-manager-files|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
Thoughts?
On my test site everything works just fine. Is this a server setting that needs to be tweaked?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 Codeigniter,您想要这样的东西:
如果这不起作用,请检查以确保
$config['index_page'] = '';
和您的 .htaccess 指令设置正确:我已经做了数百次Codeigniter 的安装在许多操作系统配置上,并且始终能够使其正常工作,但我偶尔会遇到一些问题,我必须发挥创意才能让
index.php
消失。With Codeigniter you want something like this:
If that is not working, check to make sure
$config['index_page'] = '';
and your .htaccess directives are set right:I've done hundreds of Codeigniter installs on many OS configs and have always been able to get this to work, but I have had some issues occasionally where I had to get creative to get the
index.php
to disappear.RewriteCond 是错误的。在第一个参数中,您必须使用要检查的内容。例如请求的 URI、脚本文件名等。在上面的示例中,您似乎尝试将 $1(美元和一)与重写条件的右侧部分进行比较:?
The RewriteCond is wrong. In first argument you have to use what to check. In example the requested URI, the script file name and so on. On the above example it looks like you try to compare $1 (dolar and one) to the right part of the Rewrite Condition :?