HTACCESS: How to REDIRECT ALL urls contains “a word” to only one other URL?

↘锁芯ラ 提交于 2019-12-13 01:43:57

问题


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.



来源:https://stackoverflow.com/questions/17654747/htaccess-how-to-redirect-all-urls-contains-a-word-to-only-one-other-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!