首页 > 解决方案 > 使用 .htaccess 删除 url 中的 index.php 但失败

问题描述

我创建了 .htaccess 来删除 url 中的 index.php。注销后我重定向('auth'); 但在 url 中出现 index.php 即http://localhost/myhems/index.php/auth

有谁知道为什么?

标签: codeigniter

解决方案


我不确定您正在使用什么操作系统,但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'] = '';

推荐阅读