WAMP 2.4上的Mod_rewrite [英] Mod_rewrite on WAMP 2.4

查看:44
本文介绍了WAMP 2.4上的Mod_rewrite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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_rewrite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆