【发布时间】:2018-11-04 18:34:56
【问题描述】:
我需要将网站从 Nginx Web 服务器移动到 Apache。除了与旧 URL 兼容所需的两条规则外,我成功地转换了所有内容(该网站以前是用 ASP 开发的,然后用 PHP 重写)。
这样的规则是:
location /images/index.asp {
return 301 $scheme://$server_name/image-library?$args;
}
它将https://www.domain.ext/images/index.asp?var1=somevalue&var2=someother的请求重定向到https://www.domain.ext/image-library?var1=somevalue&var2=someother
和:
location ~ ^/images/(?<year>[0-9]+)/index.asp {
return 301 $scheme://$server_name/image-library?img_year=$year&$args;
}
它将https://www.domain.ext/images/2018/index.asp?var1=somevalue&var2=someother的请求重定向到https://www.domain.ext/image-library?img_year=2018&var1=somevalue&var2=someother
您能帮我编写正确的 RedirectMatch 301 规则吗?
【问题讨论】:
-
你试过什么?见How to Ask 和minimal reproducible example。