[英]In .htaccess, how do I redirect a url when a word is alone?
I have a situation where I need to create multiple redirects. 我遇到需要创建多个重定向的情况。
I want to redirect /blog to /food, which can be easily done by 我想将/ blog重定向到/ food,可以很容易地通过
Redirect 301 /blog /food
But then I also need to redirect /blog/example to /another-example. 但是然后我还需要将/ blog / example重定向到/ another-example。 But because I created the former redirect, this is what ends up happening:
但是由于我创建了前一个重定向,因此最终发生了以下情况:
/blog/example
becomes 变
/food/example
instead of 代替
/another-example
because it's changing /blog to /food before considering anything else. 因为它在考虑其他事项之前将/ blog更改为/ food。
Any help? 有什么帮助吗? Thanks!
谢谢!
Redirect directive matches rest of the uri and appends it to the destination. 重定向指令与uri的其余部分匹配,并将其附加到目的地。 To redirect a specific uri, you need to use RedirectMatch.
要重定向特定的uri,您需要使用RedirectMatch。
RedirectMatch 301 ^/blog/?$ /food
Clear your browse cache before testing this. 在测试之前,请清除浏览缓存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.