apache - 有条件的接受语言重定向指令可能吗?
问题描述
我想达到什么目的?
/de/
如果调用主页 ( /
) 并且 HTTP 标头Accept-Language
以de
访问者浏览器的开头但仅针对特定域,我想重定向到。
这是我的出发点:
由于我有许多特定于域的重定向规则,因此我有多个<If>
指令。下面的代码片段被减少到最低限度。
<IfModule mod_rewrite.c>
RewriteEngine on
# Redirect serveral domain aliases
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?my\-domain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^(www\.)?anotherdomain\.com$
RewriteRule .* https://www.mywebsite.com/en/products/overview/ [R=301,L]
RewriteCond %{HTTP_HOST} ^(karriere|jobs)\.areal\-domain.at$
RewriteRule .* https://www.mywebsite.com/de/ueber-uns/karriere/ [R=301,L]
# Redirect language DE for homepage only of www.mywebsite.com
# (the following rule is outside of the following otherwise it will not work actually
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^$ /de/ [R=301,QSA,L]
<If "req('Host') =~ /(live.mywebsite.com|www.mywebsite.com|mywebsite.com|mywebsite.docker)/">
RedirectMatch 301 ^/$ /en/
RedirectMatch 301 ^/contact(/)?$ /en/about-us/contact/
RedirectMatch 301 ^/customer-support(/)?$ /en/service-and-support/
</If>
</IfModule>
这是我的问题:
如果我将语言重定向的重写放入<If>
指令中,apache v2.4.38 服务器确实总是发送 HTTP 状态代码 500,如下一个片段所示:
<IfModule mod_rewrite.c>
RewriteEngine on
# ...
<If "req('Host') =~ /(live.mywebsite.com|www.mywebsite.com|mywebsite.com|mywebsite.docker)/">
# Redirect language DE for homepage only of www.mywebsite.com
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^$ /de/ [R=301,QSA,L]
RedirectMatch 301 ^/$ /en/
RedirectMatch 301 ^/contact(/)?$ /en/about-us/contact/
RedirectMatch 301 ^/customer-support(/)?$ /en/service-and-support/
</If>
</IfModule>
这种行为的原因是什么?
我阅读了文档,但找不到有关我的方案的任何信息。
解决方案
推荐阅读
- performance - 如何让浏览器没有TTFB
- excel - 如何取消选择标准VBA自动过滤器
- python - 如何将最大登录尝试添加到用户名和密码来自数据库的python脚本?
- azure - k8s服务连接被拒绝
- python - Python BeautifulSoup 在没有 id 标签的情况下找不到
我是使用 BeautifulSoup 的新手,因为我想购买 2 个新的 ram 内存,所以我去网上查看很多商店中组件的价格,但我想提取有关价格的所有信息所有产品,如果其中 2 个或更多在同一商店中,请将其保存在 txt 文件中。
这是我使用 https://www
- python - 使用 unicode 的凯撒密码出现问题
- salesforce - 我们可以在 Salesforce CTI 集成中使用自动拨号器功能吗?如何在 Salesforce 中添加自动拨号器的呼叫列表?
- jq - 如何在if中达到else?
- javascript - 获取具有特定时区的当前日期和时间以用于不和谐机器人
- vue.js - vue中抓取数据时如何使用变量