0

嗨,我正在尝试.php从 url 中删除扩展名。为此,我正在关注本教程删除 .php 扩展名。但是当我将.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 服务器中测试我的所有文件。

4

3 回答 3

1

Options +SymLinksIfOwnerMatch 行是该错误的主要原因,请将其注释为

#Options +SymLinksIfOwnerMatch 

错误将删除

于 2014-12-18T18:34:20.973 回答
1

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

于 2016-02-17T06:12:50.743 回答
0

在下一行之前删除#

编辑前

#LoadModule rewrite_module modules/mod_rewrite.so

编辑后

LoadModule rewrite_module modules/mod_rewrite.so
于 2013-10-18T16:12:49.630 回答