2017-08-26 102 views
0

我没有修改.htaccess文件的经验。 我试图将自定义错误页面添加到我的网站,并从托管服务提供商(1and1)获得以下模板。我知道如何添加页面,但我想逐行理解代码正在做什么。1and1 .htaccess指令:需要说明

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule (.*) /errordocument.html 
ErrorDocument 400 /errordocument.html 
RemoveType x-mapp-php4 .html 

预先感谢您的帮助!

回答

2

让我们先从一条线:

RewriteEngine On - 很简单的一个,它说,它的名字,它使重写引擎,使我们能够做很多事情。 (我不会进入细节什么这些东西都是)

RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d主要检查什么,是不是一个文件或目录,如果这两个条件都满足时,它会移动到RewriteRule如果不,那么没有任何东西可以运行。

RewriteRule (.*) /errordocument.html - 这基本上告诉服务器,如果满足上述条件,重定向到名为errordocument.html的错误页面。 (这当然符合你的上述条件)。

ErrorDocument 400 /errordocument.html - 简单地说,这只是告诉服务器,如果收到400错误,然后显示errordocument.html页面。

最后RemoveType x-mapp-php4 .html - 这基本上是告诉你的Apache服务器从你的URL的末尾删除任何分机.html

对于更深入的信息到每个这些广泛程度如何,他们都可以使用,看看为Apache文档通过点击here

我希望这可以帮助你了解什么是对位去更好。

+0

谢谢,滞后!随着你的帮助我修复了我的.htaccess :) –