0

每次在我的 .htaccess 文件中实现此代码以进行 mod 重写时,我都会遇到错误

RewriteEngine On 
RewriteRule   ^commenting/([0-9]+)/?$commenting.php?id=$1

我正在尝试转换

domain/commenting.php?id=15

进入类似的东西

domain/commenting/15

是代码问题还是我的托管问题。我还没有下载任何插件是需要的吗?任何帮助将不胜感激,谢谢

错误是这样的:

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

Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error.

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

1 回答 1

1

您在规则的左右手之间缺少一个空格。

RewriteRule ^commenting/([0-9]+)/?$ /commenting.php?id=$1

RewriteEngine您可能还需要启用Options以下各项:

Options +FollowSymLinks -MultiViews

RewriteEngine On
RewriteRule ^commenting/([0-9]+)/?$ /commenting.php?id=$1

如果在此之后您仍然获得 500,请尝试将上述规则放在这些标签之间,<IfModule mod_rewrite.c>...</IfModule>如下所示:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews

    RewriteEngine On
    RewriteRule ^commenting/([0-9]+)/?$ /commenting.php?id=$1
</IfModule>

以上基本上意味着只有在使其工作的模块可用时才执行规则。

于 2013-08-04T02:55:25.027 回答