引用页面不起作用


Referencing a page not working

我使用的是codeigniter 3.0和examplep。当我尝试用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>

您可以尝试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

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

此外,如果您有任何包含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个示例,您可以根据您的服务器/OS系统

尝试