【问题标题】:Redirect HTTPS to HTTP and NON WWW to WWW将 HTTPS 重定向到 HTTP,将 NON WWW 重定向到 WWW
【发布时间】:2013-09-03 00:40:15
【问题描述】:

我的重定向有问题,我猜是因为我一直在复制和粘贴我的 htaccess 规则。

我需要将所有 https 流量重定向到 http,并将所有非 www 重定向到 www。我还有一些规则可以制作漂亮的链接

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}

RewriteRule (.*\.php)\.$ /$1 [R=301,L]

RewriteRule ^people/([^/]*)/([^/]*)/([^/]*)$ /profile.php?county=$1&name=$2&id=$3 [L]
RewriteRule ^people-in-(.*) /people.php?county=$1 [L]

RewriteCond %{HTTP_HOST} ^ties\.co.uk$
RewriteRule (.*) http://www.ties.co.uk/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/index.php$
RewriteRule (.*) / [R=301,L]

DirectoryIndex index.php

<IfModule mod_rewrite.c>
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

ErrorDocument 404 /notfound.php 

【问题讨论】:

    标签: apache .htaccess seo


    【解决方案1】:

    你可以组合:

    RewriteCond %{HTTPS} on
    RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
    

    RewriteCond %{HTTP_HOST} ^ties\.co.uk$
    RewriteRule (.*) http://www.ties.co.uk/$1 [R=301,L]
    

    到需要RewriteEngine On下方的单个规则

    RewriteCond %{HTTPS} on [OR]
    RewriteCond %{HTTP_HOST} ^ties\.co\.uk$ [NC]
    RewriteRUle ^(.*)$ http://www.ties.co.uk/$1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2016-10-14
      • 2012-06-09
      • 2019-10-26
      • 2018-07-03
      • 1970-01-01
      • 2017-11-24
      • 2017-03-24
      • 1970-01-01
      相关资源
      最近更新 更多