2012-04-17 60 views
70

我有一個htaccess文件,它在主機完美地工作,但是當我把它放在本地,它表明我這個錯誤:內部服務器錯誤 - htaccess的

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.

我發現在錯誤日誌文件此警報:

[Tue Apr 17 10:02:25 2012] [alert] [client 127.0.0.1] D:/wamp/www/jivan/sql/.htaccess: Invalid command 'Header', perhaps misspelled or defined by a module not included in the server configuration

這是我的htaccess文件代碼:

RewriteEngine On 
AddDefaultCharset utf-8 
RewriteRule ^([0-9-]+)/keyword_show.html$ keyword_show.php?keyword_id=$1 
RewriteRule ^page_(.*).html$ page.php?url=$1 
RewriteRule ^([0-9-]+)/(.*)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&id=$3&pagenumber=$4 
RewriteRule ^([0-9-]+)/(.*)/(.*).html$ $2.php?advertisement_cat=$1&pagenumber=$3 
RewriteRule ^([0-9-]+)/(.*).html$ $2.php?advertisement_cat=$1 
# cache images and flash content for one month 
<FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf)$"> 
Header set Cache-Control "max-age=2592000" 
</FilesMatch> 

# cache text, css, and javascript files for one month 
<FilesMatch ".(js|css|pdf|txt)$"> 
Header set Cache-Control "max-age=2592000" 
</FilesMatch> 

我的本地服務器的運行WAMP和我啓用重寫模塊呢! !

那麼有什麼問題?

+0

最佳答案[這裏](http://www.steptoinstall.com/wamp-500-internal-server-error-htaccess-php-codeigniter.html) – 2015-03-04 12:08:56

回答

98

Header指令是在mod_headers apache模塊中。您需要確保該模塊已加載到apache服務器中。

+6

謝謝......它被命名爲模塊列表中的headers_module :) – 2013-08-29 10:28:43

+2

對於懶惰只是做: ... AntonioCS 2015-04-10 15:28:00

9

試試這個:

<IfModule mod_headers.c> Header set [your_options] </IfModule> 

你有沒有安裝後重新啓動WAMP /啓用?

61

步驟啓用HEADERS模塊

$ cd /etc/apache2/mods-available 
$ sudo a2enmod headers 
$ /etc/init.d/apache2 restart 
+5

這可以是一個單行:'sudo a2enmod頭&& sudo服務apache2重新啓動(應該在基於Debian的發行版上工作)。 – 2014-08-12 17:22:22

5

在一個Ubuntu/Debian系統中,你可以簡單地運行這個命令:

sudo ln -s /etc/apache2/mods-available/headers.load /etc/apache2/mods-enabled/ 

,應該是所有設置.....

27

在你的命令行上:

安裝mod_headers

sudo a2enmod headers 

,然後重新啓動Apache

service apache2 restart 
+0

這爲我工作!謝謝 – spacebiker 2016-03-13 18:21:24