【问题标题】:codeigniter 2.1.3 htaccess not workingcodeigniter 2.1.3 htaccess 不工作
【发布时间】:2013-04-11 03:20:27
【问题描述】:

我在 ubuntu 12.10 上使用 apache2。但 htaccess 不工作,这是我的 htaccess 文件:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /ci/
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
<IfModule mod_security.c>
   SecFilterEngine Off
   SecFilterScanPOST Off
</IfModule>


$config['base_url'] = 'http://localhost/ci/index.php'; 
$config[‘index_page’] = “”;
$config[‘uri_protocol’]  = “AUTO”;


1 http://localhost/ci/index.php/site/about
2 http://localhost/ci/site/about

第一个工作,但我希望第二个工作任何想法如何使它工作。谢谢

404 Not Found
The requested URL /ci/site/about was not found on this server.

【问题讨论】:

  • 尝试删除 $config['base_url'] = 'localhost/ci/index.php';到 $config['base_url'] = ' '
  • 还是一样的错误信息

标签: php .htaccess codeigniter


【解决方案1】:

您是否启用了模组重写?

设置您的 htaccess(示例)

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

删除配置中的 index.php

$config['base_url'] = ''; 
$config['index_page'] = '';

还允许在你的 apache 中覆盖 htaccess

/etc/apache2/sites-available/default

并编辑文件并更改为

AllowOverride All

然后重启apache

【讨论】:

  • apache rewritemode 是 AllowOverride All 但我不断收到此服务器上未找到请求的 URL /ci/site/about。
  • 尝试设置你的 baseurl = ''
  • 我的基本网址是 $config['base_url'] = 'localhost/ci/index.php';我仍然收到相同的错误消息
【解决方案2】:

这是我的设置的样子,我的可以按照你喜欢的方式工作:

.htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

config.php

$config['index_page'] = '';
$config['base_url'] = 'http://localhost/icms/';

我认为这就是我所做的一切改变。

希望对你有帮助。

问候,

科布斯

【讨论】:

  • 感谢 kobus 先生的帮助,但我确实像您告诉我的那样,我不断收到请求的 URL /ci/site/about 在此服务器上找不到。 apache LOG 文件 [Thu Apr 11 20:10:10 2013] [error] [client 127.0.0.1] 文件不存在:/var/www/ci/site
  • 所以,你的 $config['index_page'] 是空白的,$config['base_url'] 等于 'localhost/ci'。当您转到localhost/ci/index.php/site/about 时,您的页面可以工作,但是当您转到9 localhost/ci/site/about 时,它不能吗?我能想到的唯一一件事是您没有将 .htaccess 信息放入 RIGHT .htaccess 文件中。我以前做过。它必须是站点文件夹根目录中的那个,而不是应用程序文件夹中的那个。除此之外,我很抱歉,但我没有任何其他帮助,因为我的工作就在那里......
  • 我尝试了所有的东西,但它不起作用,当我尝试 localhost/ci/site/about 时显示 index.php
猜你喜欢
  • 2016-03-01
  • 2012-04-29
  • 2011-05-29
  • 2015-12-16
  • 2018-03-19
  • 1970-01-01
  • 2015-08-11
  • 2020-03-02
  • 1970-01-01
相关资源
最近更新 更多