codeigniter奇怪的问题,用斜线工作的一些不列入一些链接 [英] Codeigniter strange issue, Some link with trailing slash work some doesnot

查看:90
本文介绍了codeigniter奇怪的问题,用斜线工作的一些不列入一些链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我米有奇怪的问题。我有一个codeigniter应用程序,它完全工作正常,在我的本地机器,但在远程服务器上它亘古不变的。下面是情形

I m having strange problem. I have a Codeigniter application which perfectly works fine in my local machine, but in remote server it doesnot. Following are the scenarios

  1. 与斜线的作品,但没有结尾的斜线某些链接显示连接被重置错误的Firefox浏览器。

  1. Some links with trailing slash works, but without trailing slash shows "The connection was reset" error in Firefox.

无斜线的作品一些链接,但斜线显示连接被重置错误的Firefox浏览器。

Some links WITHOUT trailing slash works, but WITH trailing slash shows "The connection was reset" error in Firefox.

我敢肯定有编码,因为没有错误。所有我认为罪魁祸首是.htaccess文件。 以下是我的.htaccess文件

I m sure there is no error in coding because. All I think the culprit is .htaccess file. Following is my .htaccess file

RewriteEngine on
RewriteBase /demo/
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

任何帮助将是非常美联社preciated。谢谢!

Any help will be highly appreciated. Thanks!

推荐答案

我相信你的问题是遗漏了'?在这条线:

I believe your issue is a missing '?' on this line:

RewriteRule ^(.*)$ index.php/$1 [L,QSA]

添加这个'?后直接的index.php

Add this '?' directly after 'index.php'

RewriteRule ^(.*)$ index.php?/$1 [L,QSA]

此外,在我的经验,我想撇下了结尾的斜线上的RewriteBase并将其添加到$配置['BASE_URL']参数,让CI做到这一点为你工作,而不是:

Also, in my experience I would leave off the trailing slash on RewriteBase and add it to the $config['base_url'] parameter and let CI do that work for you instead:

$config['base_url'] = 'http://yourwebsite.com/demo/';
-instead of-
$config['base_url'] = 'http://yourwebsite.com/demo';

这是htaccess的设置和我已经用CI的一段时间,它已使我受益匪浅:

This is the .htaccess setup i've used for a while with CI and it has served me well:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase / # TODO: add a folder name here if the application is not in web root

  RewriteCond %{REQUEST_URI} ^system.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]

  RewriteCond %{REQUEST_URI} ^application.*
  RewriteRule ^(.*)$ /index.php?/$1 [L]

  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> 

这篇关于codeigniter奇怪的问题,用斜线工作的一些不列入一些链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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