我有以下规则-
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/es/archivo/blog%{REQUEST_URI} [R=301,L]唯一的问题是重写的URL在末尾有一个.html,所以它看起来像- https://www.example.com/es/archivo/blog/......something.html。
我怎么才能把最后一个.html剪掉呢?我试过了-
RewriteRule ^(.*)\.html$ https://www.example.com/es/archivo/blog%{REQUEST_URI} [R=301,L]我希望最终的url看起来像
https://www.example.com/es/archivo/blog/......something而不是
https://www.example.com/es/archivo/blog/......something.html发布于 2017-01-06 10:19:35
您需要在target中使用从匹配模式捕获的值,如下所示:
RewriteCond %{HTTP_HOST} ^oldsite\.com$ [NC]
RewriteRule ^(.+)\.html$ https://www.example.com/es/archivo/blog/$1 [R=301,L,NC,NE]在测试此更改之前,请清除浏览器缓存。
https://stackoverflow.com/questions/41497137
复制相似问题