引用一个页面无法正常工作 [英] Referencing a page not working

查看:198
本文介绍了引用一个页面无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用codeigniter 3.0和XAMPP。当我尝试引用页面XAMPP与codeigniter它进入XAMPP索引页。

下面是我的.htaccess

 < IfModule mod_rewrite.c>
RewriteEngine叙述上
# !重要!在这里设置你的RewriteBase,不要忘记尾随和领导
#斜线。
#如果你的页面驻留在
#http://www.example.com/mypage/test1
#然后用
#的RewriteBase /我的页面/测试1 /
的RewriteBase /
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php?/ $ 1 [L]
< / IfModule>

 <!IfModule mod_rewrite.c>
#如果我们没有mod_rewrite的安装,所有404的
#可以被发送到index.php,一切工作正常。
#提交者:ElliotHaughin

的ErrorDocument 404的index.php
< / IfModule>
 

解决方案

您可以尝试的http://localhost/project/index.php/route-name 但是,如果你想这样做没有index.php文件试试下面我举的例子。

免责声明:我不知道你在运行,以便能显示出不同的结果,此系统/服务器的版本只是例子来帮助你前进

创建主目录中的文件名为的.htaccess的请勿触摸应用程序文件夹中的htaccess

 选项+了FollowSymLinks
选项​​-Indexes
的DirectoryIndex index.php文件
RewriteEngine叙述上
的RewriteCond $ l ^(指数\ .PHP |图片|机器人\ .TXT)!
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php / $ 1 [L,QSA]
 

我用的是同一个htaccess的我活的服务器上没有问题的托管服务提供商 HTTP:/ /www.arvixe.com/9875-0-1-370.html

删除的index.php 从config.php文件 $配置['index_page'] ='';

此外,如果您有任何的联系,其中包括删除的index.php也例子。

  BASE_URL(的index.php /路由名');
 

更改为

  BASE_URL(路径名);
 

  SITE_URL(的index.php /路由名');
 

更改为

  SITE_URL(路径名);
 

如果您仍然有问题,请检查您的routes.php文件,确保您已经配置在应用程序中的路径/配置/ route.php $航线['名称'] =路线名称/索引 ;。检查控制器的姓名

在codeigniter 3.0,你还需要有控制器资本。例如的welcome.php

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

I am using codeigniter 3.0 and xampp. When I try to reference a page in xampp with codeigniter it goes to the xampp index page.

Here is my .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>

解决方案

You could try http://localhost/project/index.php/route-name But if your trying to do it without index.php try my example below.

Disclaimer: I do not know what versions of system/server you are running so could show a different result this is just example to help you along.

Create a file in main directory called .htaccess Do not touch the htaccess in application folder

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]

I use the same htaccess on my live server no issues Hosting Provider http://www.arvixe.com/9875-0-1-370.html

Remove index.php from config.php $config['index_page'] = '';

Also if you have any links that include index.php remove that also example.

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

Change To

base_url('route-name');

Or

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

Change To

site_url('route-name');

If you are still having issue check your routes.php make sure you have configured your routes in application/config/route.php $route['name'] = "route-name/index"; check your name of controller.

In codeigniter 3.0 you also need to have the controller capitalized. example Welcome.php

If that does not work I found this https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter has about 5 examples you could try depending on your server / OS-system

这篇关于引用一个页面无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆