0

我有一个问题,我可以为两个或更多不同的页面使用通用的 mod 重写规则吗?例如,我有两页,下面的重写规则应该可以工作。

RewriteRule /(.*)\.html aboutus.php?pg=$1 [QSA]
RewriteRule /(.*)\.html profile.php?pg=$1 [QSA]

但是我可以使用一些通用规则,这样我就不必为每一页重复上面的内容了吗?

4

1 回答 1

0

Unless you add a RewriteCond only the first rule will have any effect because the first regex captures anything that ends with .html and then modifies it such that rule #2 will not match.

Request Example: http://domain.com/something/something/something.html?k=v

  1. /something/something/something.html matches /(.*)\.html
  2. rewrites to aboutus.php?pg=something/something/something&k=v
  3. No L flag - continue to next RewriteRule
  4. aboutus.php?pg=something/something/something&k=v does not match /(.*)\.html
  5. serve aboutus.php?pg=something/something/something&k=v
于 2013-08-06T14:31:21.390 回答