首页 > 解决方案 > 如何设置特定的 RewriteRule?

问题描述

我正在设置一个新的 RewriteRule 并且不会显示网页。它会抛出一个 HTTP 错误,如 404 或 BadRequest。这取决于我使用的组合。我想通常使用的重写是否可能?

我们要配置以下重写:

此重写有效:

RewriteRule ^/context1/contetx2/context3/context4/Reisen.de.html  https://www.test.at/context1/contetx5/context6/2018/context7/Reisen.html  [R=301,L]

但是我们想在浏览器中显示的 URL 中“删除”路径/位置“2018”。它应该看起来像: https ://www.test.at/context1/contetx5/context6/context7/Reisen.html

我已经用 R、QA、P、L、PT 进行了很多组合;ProxyPass、RewriteCond 等。

预期:输入网址: https ://www.test.at/context1/contetx2/context3/context4/Reisen.de.html

显示在浏览器(地址行)中: https ://www.test.at/context1/contetx5/context6/context7/Reisen.html

内容可通过以下方式访问: https ://www.test.at/context1/contetx5/context6/2018/context7/Reisen.html

标签: apachehttp

解决方案


尝试:

RewriteRule ^/context1/contetx2/context3/context4/Reisen.de.html  /context1/contetx5/context6/context7/Reisen.html  [R=301,L]
RewriteRule ^/context1/contetx5/context6/context7/Reisen.html  /context1/contetx5/context6/2018/context7/Reisen.html  [L]

推荐阅读