WAMP 2.4上的Mod_rewrite

时间:2014-01-16 01:53:22

标签: apache .htaccess mod-rewrite wamp

我有wampserver 2.4,我似乎无法让Mod_Rewrite处理它。我已在Apache服务中启用它并取消注释httpd.conf中的mod_rewrite.so并重新启动服务器。我还检查了我的phpinfo(),并在服务下列出了mod_rewrite。

我正在测试的网站是在地址localhost / eb / index.php后面我试图在event.php页面上测试它,其中url看起来像localhost / eb / event.php?id = 1

这是我的.htaccess文件在我的index.php文件所在的localhost / eb的根目录中的样子。

<IfModule mod_rewrite.so>
RewriteEngine on
RewriteBase /eb/
RewriteRule ^event/([0-9]+)/?$event.php?id=$1
</IfModule>

即使在此之后它仍然显示url localhost / eb / event.php?id = 1

2 个答案:

答案 0 :(得分:2)

在文档根目录而不是/ eb /目录中添加RewriteBase /eb/,并在/ eb /目录中添加所有重写。

<强>更新

在你的http.conf

<Directory *>            
   # changed from None to FileInfo
   AllowOverride FileInfo          
</Directory>

答案 1 :(得分:2)

您还需要额外的外部重定向。保持你的.htaccess像这样:

Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteBase /eb/

RewriteCond %{THE_REQUEST} /event\.php\?id=([^\s&]+) [NC]
RewriteRule ^ event/%1? [R=301,L]

RewriteRule ^event/([0-9]+)/?$ event.php?id=$1 [L,QSA]