HTACCESS: How to REDIRECT ALL urls contains “a wor

2019-08-06 02:07发布

问题:

Lets say we have the urls (which contains "vvvvv") inside. For example:

  • http://www.example.com/vvvvv
  • http://www.example.com/vvvvv/
  • http://www.example.com/vvvvv/somepage
  • http://www.example.com/some-dir/vvvvv.php?arg=whatever

All those above (containing "vvvvv" word inside) will be going to:

  • "http://www.google.com" .. only. Neatly. (To a Domain ONLY. Without any carryings/ trailing)

How to make it in .htaccess please?

回答1:

RewriteRule vvvvv http://www.google.com? [L,R=301]

That should do it I think. The ? at the end of the destination URL means "don't send any query string".



回答2:

This rule works. I've tried it with a different rule. Not sure if the ? will work, but if you use a direct URL as the final destination URL, it will function properly.