500错误时,抛出因的.htaccess错误 [英] 500 error thrown due to .htaccess bug
本文介绍了500错误时,抛出因的.htaccess错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
的.htaccess 抛出一个500错误
我使用codeIgniter和需要摆脱在URL中的index.php的。 我复制从CI教程.htaccess文件,清空$配置['index_page'] =''; 并把htaccess的根目录下。
- 没有.htaccess文件,它工作正常,但丑:www.example.com/index.php/site/home
- 出于某种原因,它不工作,只是抛出一个500的错误。
- 在日志中还有一排,重复自己在每一次尝试:[星期四 12月20号4点01分十三秒2012] [警惕] [客户2.55.118.161] /home/morro1980/data/www/knight-guard.org/.htaccess: 指令要求额外的参数。
- mod_rewrite的安装及工作
在哪里错误,我怎么能解决呢?
感谢你在前进
我的.htaccess文件:
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
#Removes用户访问到系统文件夹。
#Additionly这将允许您创建一个System.php控制器,
#previously这样就不会出现没有可能。
#'系统'可以,如果你已重命名系统文件夹进行更换。
的RewriteCond%{REQUEST_URI} ^系统。*
重写规则^(。*)$ /index.php?/$1 [L]
#当你的应用程序文件夹没有在系统文件夹
#这个片断prevents用户到应用程序文件夹的访问
Fabdrol:由#Submitted
#Rename'应用'为您的应用程序文件夹名称。
的RewriteCond%{REQUEST_URI} ^应用。*
重写规则^(。*)$ /index.php/$1 [L]
#Checks,查看是否用户正在试图访问一个有效的文件,
#such作为图像或CSS文档,如果这不是它发送的真实
#request的index.php
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则^(。*)$的index.php?/ $ 1 [L]
< IfModule>
<!IfModule mod_rewrite.c>
#如果我们没有mod_rewrite的安装,所有404的
#可被发送到index.php? ,一切工作正常。
#提交:ElliotHaughin
的ErrorDocument 404的index.php
< / IfModule>
我的网站控制器:
< PHP的,如果(定义(BASEPATH')!)出口('没有直接的脚本允许访问);
类网站的扩展是CI_Controller {
公共功能指数(){
$这个 - >家();
}
公共职能的家(){
回声默认功能开始< BR />中;
$这个 - >你好();
$数据['标题'] ='家';
$数据['名称'] ='伊利亚';
$数据['FNAME'] ='利';
$数据['操作'] ='减';
$数据['VAL1'] = 5;
$数据['val2的'] = 7;
回声$数据['操作']< BR />中。
$数据['结果'] = $这个 - >数学($的数据);
$这个 - > viewLoad(home_view,$数据);
回声< BR />中;
}
公共职能你好(){
回声你好功能开始< BR />中;
}
公共职能数学($数据){
$操作= $数据['操作'];
$ VAL1 = $数据['VAL1'];
$ val2的= $数据['val2的'];
$这个 - >负载>模型(数学);
返回$这个 - > MATH->计算($操作,$ VAL1,$ val2的)< BR />中。
}
公共职能viewLoad($ whatToView,$数据){
尝试{
$这个 - >负载>查看($ whatToView,$数据);
}赶上(异常$ E){
回声没有这样的说法;
}
}
关于公共函数(){
$数据['标题'] =关于!;
$这个 - > viewLoad(about_view,$数据);
}
}
解决方案
第一个< ifModule>
不是封闭的,这样的:
重写规则^(。*)$的index.php?/ $ 1 [L]
< IfModule>
必须
重写规则^(。*)$的index.php?/ $ 1 [L]
< / IfModule>
#^
Possible Duplicate:
.htaccess throws a 500 error
I am using CodeIgniter and need to get rid of the "index.php" in the URL. I copied the .htaccess file from CI tutorial, emptied the $config['index_page'] = ''; and put the .htaccess in the root directory.
- Without the .htaccess file it works fine, but ugly: www.example.com/index.php/site/home
- For some reason it's not working and just throws a 500's error.
- In the log there is a row that repeats itself in every attempt: [Thu Dec 20 04:01:13 2012] [alert] [client 2.55.118.161] /home/morro1980/data/www/knight-guard.org/.htaccess: directive requires additional arguments.
- The mod_rewrite is installed and working
Where is the bug and how can I resolve it?
Thank you in advance
My .htaccess file:
<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>
My site controller:
<?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);
}
}
解决方案
The first <ifModule>
is not closed, this:
RewriteRule ^(.*)$ index.php?/$1 [L]
<IfModule>
has to be
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
#^
这篇关于500错误时,抛出因的.htaccess错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文