首页 > 解决方案 > 301 从非 www 到 www 的所有 URL

问题描述

我需要将路径中所有不带 www 的 URL 与 index.php 重定向到 www 版本中的相同。

我写了这个:

RewriteCond %{HTTP_HOST} ^
RewriteCond %{REQUEST_URI} ^/index.php/it/(.*)$ [NC]
RewriteRule ^(.*)$ https://www.DOMAIN.it/$1/? [L,R=301]

但结果是: https ://www.DOMAIN.it/index.php/it/SOMETHING/

我需要: https ://www.DOMAIN.it/SOMETHING/

怎么了?谢谢大家

标签: .htaccessredirect

解决方案


解决了,我删除了请求网址:

RewriteCond %{HTTP_HOST} !^(.*)\.domain\.it$ [NC] 
RewriteRule ^index.php/it/(.*)$ https://www.domain.it/$1/ [R=301,L]

谢谢


推荐阅读