【问题标题】:htaccess - match ANY URL (in the same domain)htaccess - 匹配任何 URL(在同一个域中)
【发布时间】:2011-06-28 23:34:47
【问题描述】:

我想用 .htaccess 重写 URL

我希望 mod_rewrite 匹配任何 URL,然后将其重写为其他内容。任何 URL,我的意思是同一个域内的 URL。

任何 URL 的示例:

  • example.com
  • example.com/index.php
  • example.com/images/background.png
  • example.com/foo/bar/
  • example.com/?page=10
  • example.com/some/some/url/inside/this/domain/
  • example.com/foo/?bar=22

我希望正则表达式匹配上述任何 URL。我应该使用什么正则表达式?

【问题讨论】:

    标签: .htaccess mod-rewrite


    【解决方案1】:

    RewriteCond %{HTTP_HOST} ^(example.com|www.example.com)
    重写规则 ^(.*)$ /some-target-page.html[L,QSA]

    ^ 表示开始,$ 表示结束

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-09
      • 2015-03-14
      • 2016-09-05
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多