htaccess - match ANY URL (in the same domain)

2019-09-05 05:51发布

I want to rewrite URLs using .htaccess

I want mod_rewrite to match ANY URL and then rewrite it to something else. By ANY URL, I mean URLs inside the same domain.

Examples of ANY 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

I want the regexp to match ANY of the above URLs. What is the regexp that I should use?

1条回答
2楼-- · 2019-09-05 06:12

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

^ means start and $ means end

查看更多
登录 后发表回答