问题
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