【问题标题】:Codeigniter index.php errorCodeigniter index.php 错误
【发布时间】:2017-11-10 11:22:52
【问题描述】:

在将我的 codeigniter 项目从 xampp 服务器删除到 Live 服务器后,我在尝试访问我的主页时出现错误,而前面没有 index.php..

这是我的路线:

$route['home'] = 'Pages/view/home';

这是我的配置:

$config['index_page'] = '';
$config['base_url'] = 'http://mysite/newsite';
$config['uri_protocol'] = 'REQUEST_URI';

我的 .htaccess 文件:

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

所以当我尝试浏览 www.mysite/home 时,它​​给了我这个错误:

在此服务器上找不到请求的 URL /index.php/home。

此外,在尝试访问时遇到 404 Not Found 错误 使用 ErrorDocument 来处理请求。

但是当我浏览 www.mysite/index.php/home 时它确实可以工作

我尝试了不同的 htaccess 文件但没有成功

【问题讨论】:

  • 嗨,在您的 htaccess 中,您需要将 RewriteRule ^(.*)$ /index.php/$1 [L] 更改为 RewriteRule ^(.*)$ /newsite/index.php/$1 [L]
  • @elddenmedio 谢谢!像魅力一样工作!

标签: .htaccess codeigniter


【解决方案1】:

我在 xampp with widows 10 我用这两个

RewriteEngine on

# Next two lines get rid of trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]

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

还有

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]

还有你的基本网址,我会把 / 放在它的末尾

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-15
    • 2019-03-17
    相关资源
    最近更新 更多