添加.htaccess会导致内部服务器错误

时间:2013-07-16 10:46:14

标签: php .htaccess wamp internal-server-error

您好我正在尝试从网址中删除.php扩展名。为此,我正在学习本教程remove .php extension。但是当我将.htaccess文件添加到目录时,它会显示

Internal Server Error

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

Please contact the server administrator, admin@localhost 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.

我的.htaccess文件是:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]

怎么了?

注意:我正在测试WAMP服务器中的所有文件。

3 个答案:

答案 0 :(得分:1)

选项+ SymLinksIfOwnerMatch line是该错误的主要原因 请将其评论为

#Options +SymLinksIfOwnerMatch 

错误将删除

答案 1 :(得分:1)

要解决此问题,您需要启用mod rewrite 打开终端并打印sudo a2enmod rewrite 然后重启apache sudo service apache2 restart

答案 2 :(得分:0)

在以下行之前移除#

编辑前

#LoadModule rewrite_module modules/mod_rewrite.so

编辑后

LoadModule rewrite_module modules/mod_rewrite.so