我在文件夹的 .htaccess 文件中犯了什么错误


What mistake I'm making in .htaccess file for my folder?

我正在使用HTTP Apache网络服务器和PHP。

我在"www"文件夹中有一个名为"rest"的文件夹,我在其中创建了一个 .htaccess 文件并将以下代码写入其中。

# Turn on the rewrite engine
Options + FollowSymlinks
RewriteEngine on
# Request routing 
RewriteRule ^([a-zA-Z_-]*)$ index.php?name=$1 [nc, qsa]

然后我在浏览器中从这个文件夹中运行索引.php文件,然后在浏览器中出现以下错误。

**Internal Server Error**
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.

之后,我在文件/var/log/apache2/error.log中检查了apache错误日志。我在那里找到了以下行:

[Sat Jan 17 13:02:13.470123 2015] [core:alert] [pid 1297] [client 127.0.0.1:42956] /var/www/rest/.htaccess: Illegal option
这里有

语法错误:[nc, qsa](中间有空格)。

您可以使用:

# Turn on the rewrite engine
Options + FollowSymlinks
RewriteEngine on
# Request routing, skip directories
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-z_-]+)$ index.php?name=$1 [L,NC,QSA]

打开重写引擎

选项 +关注符号链接重写引擎开启

请求路由

RewriteRule ^([a-zA-Z_-]*)$ index.php?name=$1 [nc,qsa]