0

我有 3 个网址,我想重写:

`health.php?news=apple` to `/health/news/apple`

health.php?info=apple/health/info/apple
health.php?articles=apple_/health/articles/apple

为此,我在给定的代码下面写:

RewriteRule ^health health.php
RewriteRule health/news/(.*) /health.php?news=$1 [NC,QSA]
RewriteRule health/info/(.*) /health.php?info=$1 [NC,QSA]
RewriteRule health/articles/(.*) /health.php?articles=$1 [NC,QSA]

但这不起作用。请帮我。

提前致谢。

4

1 回答 1

1
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^health/(.*)/(.*) health.php?$1=$2 

上面的代码将重定向到健康页面,然后使用第一个变量作为获取变量键,第二个作为值。

于 2013-09-06T08:48:30.987 回答