Php .htaccess抛出一个500错误
我正在使用CodeIgniter,需要去掉URL中的“index.php”。 我从codeigniter教程复制了.htaccess文件,清空了$config['index_page']=''; 并将.htaccess放在根目录中。 如果没有.htaccess文件,它工作得很好,但很糟糕:www.example.com/index.php/site/home 由于某种原因,它不起作用,只是抛出了一个500的错误 错误在哪里?我如何解决它 先谢谢你 我的.htaccess文件:Php .htaccess抛出一个500错误,php,.htaccess,codeigniter,Php,.htaccess,Codeigniter,我正在使用CodeIgniter,需要去掉URL中的“index.php”。 我从codeigniter教程复制了.htaccess文件,清空了$config['index_page']=''; 并将.htaccess放在根目录中。 如果没有.htaccess文件,它工作得很好,但很糟糕:www.example.com/index.php/site/home 由于某种原因,它不起作用,只是抛出了一个500的错误 错误在哪里?我如何解决它 先谢谢你 我的.htaccess文件: <IfMod
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folders by users.
#Additionly this will allow you to create a System.php controller,
#previously this would not have not been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^{.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
<IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php? and everything works as normal.
# submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
重新启动发动机
重写基/
#删除用户对系统文件夹的访问权限。
#此外,这将允许您创建System.php控制器,
#以前这是不可能的。
#如果已重命名系统文件夹,则可以替换“系统”。
重写COND%{REQUEST_URI}^系统*
重写规则^{.*$/index.php?/$1[L]
#当应用程序文件夹不在系统文件夹中时
#此代码段阻止用户访问应用程序文件夹
#提交人:Fabdrol
#将“应用程序”重命名为应用程序文件夹名称。
重写cond%{REQUEST_URI}^应用程序*
重写规则^(.*)$/index.php/$1[L]
#检查用户是否试图访问有效文件,
#例如图像或css文档,如果这不是真的,它会发送
#请求index.php
重写cond%{REQUEST_FILENAME}!-f
重写cond%{REQUEST_FILENAME}!-d
重写规则^(.*)$index.php?/$1[L]
#如果我们没有安装mod_rewrite,所有404
#可以发送到index.php吗?一切正常。
#提交人:ElliotHaughin
ErrorDocument 404/index.php
我的网站管理员:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Site extends CI_Controller {
public function index(){
$this->home();
}
public function home(){
echo "default function started.<br/>";
$this->hello();
$data['title'] = 'Home!';
$data['name'] = 'Ilia';
$data['fname'] = 'Lev';
$data['operation'] = 'minus';
$data['val1'] = 5;
$data['val2'] = 7;
echo $data['operation']."<br/>";
$data['result'] = $this->math($data);
$this->viewLoad("home_view", $data);
echo "<br/>";
}
public function hello(){
echo "hello function started.<br/>";
}
public function math($data){
$operation = $data['operation'];
$val1 = $data['val1'];
$val2 = $data['val2'];
$this->load->model("math");
return $this->math->calculate($operation, $val1, $val2)."<br/>";
}
public function viewLoad($whatToView, $data){
try{
$this->load->view($whatToView, $data);
}catch(Exception $e){
echo "There is no such view";
}
}
public function about(){
$data['title'] = "About!";
$this->viewLoad("about_view",$data);
}
}
如果这确实是.htaccess
文件的一部分,则会导致您的问题:
RewriteRule ^{.*)$ /index.php?/$1 [L]
^^^ typo?
应该是:
RewriteRule ^(.*)$ /index.php?/$1 [L]
如果这确实是.htaccess
文件的一部分,则会导致您的问题:
RewriteRule ^{.*)$ /index.php?/$1 [L]
^^^ typo?
应该是:
RewriteRule ^(.*)$ /index.php?/$1 [L]
我也有同样的问题,但我的代码是正确的,我使用的是wamp服务器,然后
我发现重写模块未启用
于是转到apache/conf/httpd.conf和未注释行
LoadModule rewrite_module modules/mod_rewrite.so
现在它工作正常。我也有同样的问题,但我的代码是正确的,当时我正在使用wamp服务器
我发现重写模块未启用
于是转到apache/conf/httpd.conf和未注释行
LoadModule rewrite_module modules/mod_rewrite.so
现在工作正常。您是否安装了mod_rewrite
,并且在包含htaccess
文件后是否重新启动了apache
?您的CodeIgniter是否也安装在名为knight guard.org
的子目录中?没有重新启动apache,我也不知道mod_rewrite,因为我没有访问安装在我的服务器上的模块,或者不知道在哪里可以找到它。Apache有一个错误。日志
。当你收到服务器错误时,请查看那里。以防我最后的评论不清楚。你应该仔细检查你的RewriteBase/knight guard.org/
,这通常只是RewriteBase/
,除非你的应用程序是inside是一个子目录。还记得在对.htaccess
文件进行更改后总是重新启动apache
。那么这是否解决了您的问题?您是否安装了mod_rewrite
,并且在包含htaccess
文件后是否重新启动apache
?您的CodeIgniter是否也安装在子目录ca中lledknight guard.org
?没有重新启动apache,我也不知道mod_重写的情况,因为我要么无法访问服务器上安装的模块,要么不知道在哪里可以找到它。apache有一个错误。log
。当你收到服务器错误时,请查看那里。以防我最后的评论不清楚。你应该仔细检查您的RewriteBase/knight guard.org/
,这通常只是RewriteBase/
,除非您的应用程序位于子目录中。还记得在对.htaccess
文件进行更改后总是重新启动apache
。那么这解决了您的问题吗?嗯……上面代码中的“^^^^^键入”在哪里?还是我刚刚解决了我真的不明白你的意思…@Ilia Lev(
而不是{
@llialev在.htaccess中的第10行
周围你有一个大括号{
,那应该是一个括号(
@Ilia-Lev你应该回答你问题下面Steven Farley的最后一个问题。不幸的是,OP退出了,去了其他地方:嗯……上面代码中的“^^^^^错别字”在哪里?或者我只是没有真正理解你…@Ilia-Lev(
而不是{
@llialev在你的.htaccess第10行附近你有一个大括号{
,那应该是一个括号(
@Ilia Lev你应该回答你问题下面的Steven Farley的最后一个问题。不幸的是,OP退出了,去了其他地方: