.htaccess中的WAMP Apache重写问题

sho*_*rif 1 apache .htaccess mod-rewrite wamp

我正在WAMP环境中尝试创建一个裸骨前控制器并开始在我的项目根目录中创建.htaccess文件(即www/molecule/.htaccess包含:

Options +FollowSymLinks
IndexIgnore */*
# Turn on the RewriteEngine
RewriteEngine On
#  Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
Run Code Online (Sandbox Code Playgroud)

在我的WAMP设置中启用了Apache rewrite_module,并且在httpd.conf中也没有注释,但是当我尝试在目录中加载带有.htaccess的任何页面时出现内部服务器错误.Apache错误日志读取:

[alert] [client 127.0.0.1] C:/wamp/www/molecule/.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Run Code Online (Sandbox Code Playgroud)

有人能指出我正确的方向吗?

Jon*_*Lin 7

看起来你没有打开你的mod_rewrite模块.找到你的httpd.conf文件并进行搜索mod_rewrite,该行应如下所示:

LoadModule rewrite_module modules/mod_rewrite.so
Run Code Online (Sandbox Code Playgroud)

确保通过移除#前面的内容来取消注释.