codeigniter - 使用 .htaccess 删除 url 中的 index.php 但失败
问题描述
我创建了 .htaccess 来删除 url 中的 index.php。注销后我重定向('auth'); 但在 url 中出现 index.php 即http://localhost/myhems/index.php/auth
有谁知道为什么?
解决方案
我不确定您正在使用什么操作系统,但mod_rewrite
如果您正在使用,请确保已启用,linux
然后按照以下步骤操作,这是最简单的.htaccess
规则:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
将此文件保存在您的 中FCPATH
,然后转到您的config.php
下方application/config
并确保将其设置为base_url
:
$config['base_url'] = 'http://localhost/myhems/';
并删除 inindex.php
中的值:
$config['index_page'] = '';
推荐阅读
- ipaf - 起搏自动化框架中的图像比较
- kubernetes - 如何将 k8s pod 输出导航到外部负载均衡器 IP
- nosql - 如何删除 couchdb 数据库中文档的旧版本?
- javascript - 将 WebView 放大到特定的 HTML 元素
- java - 如何通过 Jsoup 获取亚马逊链接的 img url
- javascript - 将所有表单答案存储在一个文件中
- python - 如何让这个 OCR 模型与可变长度示例一起工作?
- jq - 在两个文件上运行相同的 jq 管道并比较结果?
- python - Django - 加入两个没有外键的表
- java - 使用同一类对象的两个不同引用调用同步方法