在 .htacess 中启用 ReWriteLog 后,我无法打开我的网站。

在 .htacess 中启用 ReWriteLog 后,我无法打开我的网站。

.htaccess 一开始没问题,后来我又在 .htaccess 中添加了两行来启用 RewriteLog。结果就是我打不开我的网站。

我在 .htaccess 中添加的两行内容如下:

RewriteLog /home/bigmeow/mylog/rewrite.log
RewriteLogLevel 9

启用rewritelog的.htaccess如下:

less .htaccess
RewriteEngine On
RewriteBase /blog/
RewriteLog /home/bigmeow/mylog/rewrite.log
RewriteLogLevel 9
RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
RewriteRule . index.php [L]

当我尝试打开我的网站时收到错误消息:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 

我从 error.log 中收到的错误消息:

[Thu Aug 16 08:55:16 2012] [alert] [client xx.xx.xx.96] /home/bigmeow/bigmeow.com/blog/.htaccess: RewriteLog not allowed here, referer: http://bigmeow.com/blog/linuxcmd/?p=68  

那么如果我想让RewriteLog正常工作,我应该怎么做呢?

答案1

如下所示,您无法将 RewriteLog 添加到 .htaccess。如果您想设置 RewriteLog,则必须将其添加到服务器配置或虚拟主机配置。

RewriteLog Directive
Description:    Sets the name of the file used for logging rewrite engine processing
Syntax:         RewriteLog file-path
Context:        server config, virtual host

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog

答案2

您需要将其放入您的httpd.conf,请参见此处:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog

上下文:服务器配置,虚拟主机

您不能将其放入 中.htaccess

相关内容