【发布时间】:2014-07-10 00:44:58
【问题描述】:
我在网上浏览了一些 codeigniter 教程,但我被困在重写 uri 上。
这是我的 .htaccess 代码。
RewriteEngine On
RewriteBase jrdash
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]
我也对配置文件进行了此更改。
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = '';
.htaccess 文件位于根项目文件夹中,项目目录是我的 xampp htdocs 目录中的 jrdash。当我尝试通过键入 localhost/jrdash 来加载页面时出现错误,我之前获得了默认的 Codeigniter 屏幕,但后来我进行了这些更改,现在我得到了一个错误。
【问题讨论】:
-
每个重写规则中
index.php之后的?是什么?此外,除非您使用别名目录,否则很少需要RewriteBase。我建议删除它 -
我不确定,我从正在看的教程中复制了代码。
-
呃,你必须观看的任何教程(我认为它是 phpcodeacademy YouTube 频道中那些糟糕的视频之一)都不值得关注。
-
我在 Udemy 上观看 BrutalStorm 的 PHP Codeigniter。不知道如何学习 Codeigniter,所以我认为这将是一个好的开始。有什么建议吗?
-
@Phil
.htaccess不是我的强项,但这个问号使我的一些项目在某些托管环境中正常工作,如果没有它,它们将失败
标签: php apache .htaccess codeigniter mod-rewrite