【问题标题】:Codeigniter Remove index.php from Browser UrlCodeigniter 从浏览器 URL 中移除 index.php
【发布时间】:2016-05-06 21:50:54
【问题描述】:

我想创建一个应用网址“http://example.com”。但是输入 url,它显示“HTTP Error 403.14 - Forbidden”。当我在 'http://example.com/index.php' 之类的 url 的最后插入'index.php' 时,登录页面正在浏览器中呈现 我已经改了

$config['base_url'] = 'http://example.com';

$config['index_page'] = '';

$config['uri_protocol'] = 'REQUEST_URI';

在 config.php 文件中。然后我将 .htaccess 文件与应用程序和系统文件夹一起放在 codeigniter 根文件夹中。然后在 .htaccess 文件中我用

编码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

我只想从 url 中删除“index.php”。我正在使用 IIS 8.5 网络服务器。

【问题讨论】:

  • 很抱歉,由于没有任何 IIS 经验,我无法给您准确的答案。但是这里列出了几个答案。第二个答案对我有用。 stackoverflow.com/questions/1445385/… 您可能会尝试的另一件事是多编辑 .htaccess “RewriteBase / RewriteRule 上的 RewriteEngine ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L]"
  • 我已经这样了,但没用。 apache 和 iis 的工作方式一样吗
  • 好像不行:stackoverflow.com/questions/25439087/… 那么试试这个。实际上,您似乎还需要 URL Rewrite 模块,并且规范(conf)看起来与 apache 不同。
  • 你使用什么版本的 CI?
  • 我用你的代码编辑了 .htaccess “RewriteBase / RewriteRule 上的 RewriteEngine ^(application|system|\.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond % {REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L]" 和 o/p 是相同的“HTTP Error 403.14 - Forbidden”

标签: php .htaccess codeigniter url iis-8.5


【解决方案1】:
  htaccess file
  RewriteEngine on
  RewriteCond $1 !^(index\.php|resources|robots\.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]

  my site is working http://demo.crowdfundingscript.com/ 
  config file
  $config['uri_protocol']   = 'AUTO';
   $config['index_page'] = '';

【讨论】:

  • 仍然显示相同的错误。我是否更改了根目录中的 index.php 文件
【解决方案2】:

替换这一行:-

$config['uri_protocol'] = 'REQUEST_URI';
to
$config['uri_protocol'] = 'AUTO';

还可以更改您的基本网址,如下所示。

$config['base_url']    = 'http://'.$_SERVER['HTTP_HOST'].'/';

将你的规则写如下:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]

希望它对你有用:)

【讨论】:

  • 结果也一样。
  • 为什么要改变“$config['uri_protocol'] = 'REQUEST_URI';”到“$config['uri_protocol'] = 'AUTO';”
【解决方案3】:

在 config.php 中,

删除 $config['index_page'] 中的 index.php

例如:

$config['index_page'] = '';

【讨论】:

    猜你喜欢
    • 2016-05-14
    • 2014-10-28
    • 2012-06-15
    • 2012-09-21
    • 2011-10-12
    • 2017-07-16
    • 2014-02-28
    相关资源
    最近更新 更多