如何修复本地主机上的 .htaccess mod_rewrite 服务器错误

How to fix .htaccess mod_rewrite server error on localhost

上下文

我有一个用户可以创建文章的网站。我正在尝试使用 mod_rewrite 使我的链接包含文章标题以用于 SEO 目的。不过,首先,我只是想在重写的 URL 中获取文章和用户的 ID,因为这是我访问文章的方式。我一般不熟悉正则表达式和编辑文件配置,所以我一直在尝试了解这些 mod_rewrite 行的情况。我仍然无法理解为什么代码不起作用。

问题

我的本地主机上有一个 URL,localhost/Real%20Website/readArticles.php?article_id=86&userid=64

我想将其更改为 localhost/Real%Website/readArticles/86/64

为此,我将以下代码添加到我的 .htaccess 文件中:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME}\.php -f

RewriteRule ^readArticles/([0-9+])/([0-9]+) readArticles.php?article_id=&userid= [NC, L]

使用此代码,出现以下错误:

Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

If you think this is a server error, please contact the webmaster.

Error 500
localhost
Apache/2.4.46 (Unix) OpenSSL/1.1.1h PHP/7.4.12 mod_perl/2.0.11 Perl/v5.32.0

我不确定这里的问题是什么。是因为我必须考虑 Real Website 文件夹吗?

问题

如何使用上面给出的代码修复此服务器错误?

如果有任何问题,请告诉我。

正如@arkascha 指出的那样,[NC, L] 有一个额外的 space;它应该是 [NC,L]。这解决了问题。