0

我正在使用 codeigniter 3.0 和 xampp。当我尝试使用 codeigniter 引用 xampp 中的页面时,它会转到 xampp 索引页面。

这是我的 .htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and     leading
#  slashes.
# If your page resides at
#  http://www.example.com/mypage/test1
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

 <IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php
</IfModule>
4

1 回答 1

1

您可以尝试http://localhost/project/index.php/route-name但是如果您尝试在没有 index.php 的情况下执行此操作,请尝试下面的示例。

免责声明:我不知道您正在运行什么版本的系统/服务器,因此可能会显示不同的结果,这只是帮助您的示例。

在主目录中创建一个名为 .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 没有问题 托管服务提供商http://www.arvixe.com/9875-0-1-370.html

index.php从 config.php 中删除$config['index_page'] = '';

此外,如果您有任何包含 index.php 的链接,请删除该示例。

base_url('index.php/route-name');

改成

base_url('route-name');

或者

site_url('index.php/route-name');

改成

site_url('route-name');

如果您仍然遇到问题,请检查您的 routes.php 确保您已在 application/config/route.php 中配置了您的路由,$route['name'] = "route-name/index";请检查您的控制器名称。

在 codeigniter 3.0 中,您还需要将控制器大写。示例 Welcome.php

如果这不起作用,我发现这个https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter有大约 5 个示例,您可以根据您的服务器/操作系统系统尝试

于 2015-02-13T09:57:37.770 回答