【发布时间】:2016-09-08 11:56:07
【问题描述】:
这实际上是我第一次将 CodeIgniter 项目上传到 Web 服务器。我无法访问其他页面,但默认控制器的 index() 可以正常工作。
我在互联网上搜索过相同的情况,但找不到任何解决方案。
这是 .htaccess 文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /schoolportal
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
当我尝试删除 RewriteBase 或将其更改为仅“/”时,我收到 404 Not Found 错误。
这里是配置文件:
$config['base_url'] = 'http://sctportal.org/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
还有路由文件:
$route['default_controller'] = 'SchoolPortal';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
【问题讨论】:
-
首先您需要确保启用了重写模块?
-
如何知道它是否启用?
-
使用 phpinfo();函数和搜索重写
-
我在那里看不到任何关于 mod rewrite 的信息。确切的选项名称是什么?
-
尝试将此行更改为
RewriteRule ^(.*)$ index.php?/$1 [L]。注意额外的问号。
标签: php .htaccess codeigniter