Apache-2.2

在 .htacess 中啟用 ReWriteLog 後,我無法打開我的網站。

  • August 16, 2012

.htaccess 一開始執行良好,然後我在 .htacess 中添加了兩行以啟用 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, webmaster@bigmeow.com 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 執行良好,我應該怎麼做?

如下所示,您無法將 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

你需要把它放在你的httpd.conf,見這裡:

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

上下文:伺服器配置,虛擬主機

你不能把它放在一個.htaccess.

引用自:https://serverfault.com/questions/418303