【发布时间】:2012-08-17 13:06:41
【问题描述】:
抱歉,我更改了上一个问题。我在 localhost 上的 .htaccess 重写规则有问题,我在 http://localhost/testing/.htaccess 中有 .htaccess 文件。 我想更改如下网址
http://localhost/testing/site.php?site=test
到
http://localhost/testing/test
我在 .htaccess 中有代码
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ site.php?site=$1 [L]
哪个工作正确,但我也有类似的网址
http://localhost/testing/pages.php?site=test&pid=2
这里 pages.php 有两个参数作为站点名称和页面 id。我想把它改写为
http://localhost/testing/test/2
对于这两种情况,我的以下代码都不起作用
RewriteEngine on
RewriteRule ^([^/\.]+)/?$ site.php?site=$1 [L]
RewriteRule ^([^/\.]+)/?$ pages.php?site=$1&pid=$2 [L]
请帮忙
谢谢:)
【问题讨论】:
-
你确定你在你的 xampp 中激活了 mod_rewrite 吗?
-
是的,我在
RewriteEngine on RewriteRule home index.php上工作,它正在工作......在测试/主页上 -
删除了 $ 符号,但仍然不起作用:P
标签: php html .htaccess url redirect