php - 如何删除网址中的index.php

标签 php .htaccess codeigniter

我尝试删除 Codeigniter 中的索引页

我这样做的第一步 //旧代码

$config['index_page'] = "index.php”

//新更新代码(只需删除index.php)

$config['index_page'] = ""

然后第二步我这样做 在 codigniter 的根目录中创建文件 .htaccess 然后将此代码源放入

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

but it's the same problem and I can't refresh the web page

对于索引页,URL 有效:http://localhost:8089/codeigniter3/index.php/Hello/dispdata 但没有索引页不起作用http://localhost:8089/codeigniter3/Hello/dispdata

您好,管理员, 最后感谢您的帮助,:)

最佳答案

问题是,您将其安装在 /codeigniter3/

这应该可以修复它:

// remove index.php
$config['index_page'] = ""

// Allow installation in a subfolder of your webroot
$config['uri_protocol'] = "REQUEST_URI"

并保留您的重写设置,它们就可以了。

关于php - 如何删除网址中的index.php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59860504/

相关文章:

php - 数据未插入生产站点的数据库

php - Google Calendar API 出错 - 添加日历事件时需要 401 登录

php - PHP 中来自数据库同一个表的依赖下拉列表

php - 如何从符号链接(symbolic link)获取文件路径?

html - 如何指定 Vary : Accept-Encoding header?

.htaccess - 如何让 MAMP 读取 .htaccess 文件

PhP(Codeigniter)在foreach循环之前合并查询结果

PHP SwiftMailer 无法在 SMTP 服务器上进行身份验证

php - PDO 响应 json

javascript - 为什么这个简单的 CORS GET 会失败?