缩小太宽的当前apache重定向语句的范围

缩小太宽的当前apache重定向语句的范围,apache,.htaccess,redirect,mod-rewrite,Apache,.htaccess,Redirect,Mod Rewrite,我现在有两个重定向语句- RedirectMatch permanent "/(.*)\.html$" "https://www.example.com/archive/blog/$1" RedirectMatch permanent "/(.*)" "https://www.example.com/archive/blog" RedirectMatch permanent "/(.*)\.html$" "https://www.example.com/es/archivo/blog/$1"

我现在有两个重定向语句-

RedirectMatch permanent "/(.*)\.html$" "https://www.example.com/archive/blog/$1"
RedirectMatch permanent "/(.*)" "https://www.example.com/archive/blog"

RedirectMatch permanent "/(.*)\.html$" "https://www.example.com/es/archivo/blog/$1"
RedirectMatch permanent "/(.*)" "https://www.example.com/es/archivo/blog"
我想要发生的是,当某人在西班牙语页面上时,他们将被重定向到西班牙语www.example.com页面。这与此处的第二组to规则相对应

现在的情况是,西班牙语和英语URL都在第一条重定向规则上匹配,因为它们都有.html结尾,所以它总是只重定向到第一条规则

我如何设置这两个重定向语句,以便提取URL中的差异

例如,使用这些规则,转到-
http://www.oldsite.com/2016/11/article.html
会将我重定向到正确的第一条规则

如果我将其设置为URL-
http://www.oldsite-es.com/2016/11/article.html
它还将我重定向到第一条规则,这是不正确的,因为它是es(西班牙语)页面

编辑-

这是我尝试过的一个新的重定向语句,它不太有效-

<If "%{HTTP_HOST} = '^oldsite-es\.com$'">
   RedirectMatch permanent "/(.*)\.html$" "https://www.example.com/es/archivo/blog/$1"
   RedirectMatch permanent "/(.*)" "https://www.example.com/es/archivo/blog"
</If>

重定向匹配永久“/(.*)\.html$”https://www.example.com/es/archivo/blog/$1"
重定向匹配永久“/(*)”https://www.example.com/es/archivo/blog"

如何修改重定向规则以同时使用这两个URL主机?

因此,根据您的评论,您需要使用mod_rewrite而不是mod_alias,这样您就可以根据主机名进行匹配,并对匹配进行创新以获得一个规则

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(?:www\.)?oldsite(-es)?\.com [NC]
RewriteRule ^ http://www.example%1.com%{REQUEST_URI} [R=301,L]

这是您试图从旧URL重定向到新URL的内容吗?是的,www.oldsite.com/../olddocument.html到www.example.com/../newdocument.html,www.oldsite-es.com/../olddocument.html到www.example-es.com/../newdocument.html。基本上,当前的语句太贪婪了,不能在两个不同的hsot URL之间进行区分。
{REQUEST\u URI}
部分是什么允许它匹配跟踪URL/之后的内容到新站点的?EX-oldsite.com/sometuff/document到新的URL www.example.com/sometuff/document?