我现在有一个工作URL:网址国防部重写的
http://example.com/security-services.php?service=fixed-camera-surveillance
,然后我有PHP说,$_REQUEST['service']
做一些东西...
但我想要实现相同的功能,如果URL看起来像这样:
http://example.com/security-services/fixed-camera-surveillance
谢谢!如果您使用的是.conf文件
RewriteRule ^security-services/(.*)/? /security-services.php?service=$1
,改变^
到^/
谢谢回答! 我已经完成了你的建议并且页面加载正常。我面临的唯一问题是捕获'服务'变量。 比方说,我想测试它,我会有原始示例: http://example.com/security-services.php?service=fixed-camera-surveillance 并且可以使用“echo $ _REQUEST [“服务”]“ 新的例子, http://example.com/security-services/fixed-camera-surveillance 我想”固定摄像头的监控”被回显。 建议? – 2009-11-09 20:52:03
你试过了吗?上面的代码实现了它,它使用'(。*)'正则表达式找到任何东西,并将它转储到你看到$ 1的地方,所以你的脚本在'security-services.php'文件中。 – MalphasWats 2009-11-09 21:05:09
是的,我试过了,我想从网址'...'/ security-services/fixed-camera-sur中捕获'固定摄像机监控' veillance”。我会像以前一样询问['service']吗,还是只存储在$ 1中? – 2009-11-09 21:18:07