【问题标题】:How to remove index.php in url codeigniter with wampserver如何使用 wampserver 删除 url codeigniter 中的 index.php
【发布时间】:2015-12-08 01:28:50
【问题描述】:

美好的一天,我是 codeigniter 的新手程序员。我刚刚开始测试 codeigniter 的教程指南。制作 Home.php、about.php,并在数据库中插入/查看数据。

我想问一下,如何去掉url中的index.php?我尝试了很多批准结果,我只是问了同样的问题。使用教程、youtube 教程中的示例代码制作 .htaccess,并在此 stackoverflow 中回答。我只是在做codeigniter的基础教程,但是当我删除URL中的index.php时,页面找不到我的about.php或/news/create。

顺便说一句,我使用 wamp 服务器。对不起,如果我的英语太糟糕了。提前致谢。

【问题讨论】:

标签: php .htaccess codeigniter url-routing wampserver


【解决方案1】:

首先确保在 wamp 上启用了 mod rewrite 模块转到

Apache > Apache modules

向下滚动列表以重写模块启用它。

重启 wamp。

然后试试这个 .htaccess 并将其添加到主目录。

.htaccess

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

这里有更多可用的 htaccess Click Here

目录

application

system

.htaccess

index.php

然后在您的 config.php 文件中添加基本 url,不要留空。

$config['base_url'] = 'http://localhost/project/';

$config['index_page'] = '';

【讨论】:

  • 早安先生.. 如果我的 wamp 服务器没有重写模块?我要下载吗?
  • 如果你从这里下载新的,wampserver.com/en 应该在使用时包含它是给我的。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-10
  • 2015-10-24
  • 1970-01-01
  • 1970-01-01
  • 2012-12-19
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多