Apache的条件RedirectMatch [英] Apache Conditional RedirectMatch

查看:98
本文介绍了Apache的条件RedirectMatch的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从/博客网站/到Web根目录。我创建了一个RedirectMatch 301我的网址我相信这是正确的:

I have moved a website from /blog/ to the web root. I created a RedirectMatch 301 for my URLs which I believe is correct:

RewriteEngine On
RewriteBase /
RedirectMatch 301 ^/blog/(.*)$ /$1

这正常工作。现在,domain.tld /博客/富/重定向到domain.tld /富/

This works correctly. Now, domain.tld/blog/foo/ redirects to domain.tld/foo/

不过,有一个问题。没有与塞网站上的页面:/博客/

However, there is one issue. There is a page on the website with the slug: /blog/

现在你不能因为domain.tld /博客访问页面/重定向到domain.tld /

Now you can't access the page since domain.tld/blog/ redirects to domain.tld/

所以,我想完成什么不是重定向/博客/,但重定向/博客/家居/其它/

So what I would like to accomplish is not to redirect /blog/, but to redirect /blog/everything/else/

domain.tld /博客/不重定向

domain.tld/blog/ no redirection

domain.tld /博客/富/重定向到domain.tld /富/

domain.tld/blog/foo/ redirects to domain.tld/foo/

domain.tld /博客/富/酒吧/重定向到domain.tld /富/酒吧/
等等。

domain.tld/blog/foo/bar/ redirects to domain.tld/foo/bar/ Etc.

非常感谢您的帮助!

推荐答案

你可以试试这个?我想这需要一点变化:

Can you try this? I think it needs a little change:

RewriteEngine On
RewriteBase /
RedirectMatch 301 ^/blog/(.+)$ /$1

记住测试前清除缓存+历史上的浏览器,浏览器记住301重定向规则。

Remember to clear cache + history on browsers before testing, browsers remember 301 redirect rules.

希望有所帮助。

这篇关于Apache的条件RedirectMatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆