我有wampserver 2.4,但似乎无法让Mod_Rewrite对其进行工作.我已经在Apache服务中启用了它,并在httpd.conf中取消了对mod_rewrite.so的注释,然后重新启动了服务器.我还检查了我的phpinfo(),它在服务下列出了mod_rewrite.
I have wampserver 2.4 and I can not seem to get Mod_Rewrite to work on it. I have enabled it in the Apache services and uncommented the mod_rewrite.so in the httpd.conf and restarted the server. I also checked my phpinfo() and it listed mod_rewrite under services.
我要对其进行测试的网站位于地址localhost/eb/index.php的后面,我试图在event.php页面上对其进行测试,其中的URL看起来像localhost/eb/event.php?id = 1
The site I am testing it on is behind the address localhost/eb/index.php I was trying to test it on the event.php page in which the url looks like localhost/eb/event.php?id=1
这是我的.htaccess文件在index.php文件所在的localhost/eb根目录中的样子.
This is what my .htaccess file looks like in the root of localhost/eb where my index.php file is located.
<IfModule mod_rewrite.so> RewriteEngine on RewriteBase /eb/ RewriteRule ^event/([0-9]+)/?$event.php?id=$1 </IfModule>即使在此之后,它仍然显示url localhost/eb/event.php?id = 1
Even after this it still displays the url localhost/eb/event.php?id=1
推荐答案您还需要额外的外部重定向.保持您的.htaccess如下:
You need an additional for external redirect also. Keep your .htaccess like this:
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]更多推荐
WAMP 2.4上的Mod
发布评论