V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
xiaolvmu
V2EX  ›  问与答

求助:顶级域名强制 https,二级域名强制 http。

  •  
  •   xiaolvmu · Jan 5, 2015 via Android · 4775 views
    This topic created in 4129 days ago, the information mentioned may be changed or developed.
    目前,我的.htaccess 是这样写的:
    </code># BEGIN SSL
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [QSA,L]
    FileETag none
    </IfModule>
    # END SSL


    # GZIP BEGIN
    <IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    AddOutputFilterByType DEFLATE text/css application/x-javascript
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 2 months"
    </IfModule>
    # GZIP END

    # RULE BEGIN
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    #RULE END

    #BLOG BEGIN
    RewriteCond %{HTTP_HOST} ^(www.)?xiaolvmu.techllage.com$
    RewriteCond %{REQUEST_URI} !^/xiaolvmu/
    RewriteRule ^(.*)$ /xiaolvmu/$1
    RewriteCond %{HTTP_HOST} ^(www.)?xiaolvmu.techllage.com$
    RewriteRule ^(/)?$ xiaolvmu/index.php [L]
    #BLOG END<code>

    现在,我想仅仅让 techllage.com 这个顶级域名进行 https 跳转。明明声明了 RewriteBase /,但是为什么二级域名还是会跳转 https 呢?
    这该怎么办?
    4 replies    2015-01-06 20:08:17 +08:00
    0x1e240
        1
    0x1e240  
       Jan 6, 2015 via Android
    把rewrite规则放到htaccess里面,每个子域对应一个htaccess就可以了
    Septembers
        2
    Septembers  
       Jan 6, 2015
    STS
    xiaolvmu
        3
    xiaolvmu  
    OP
       Jan 6, 2015 via Android
    @Septembers 额,这个是……什么?
    xiaolvmu
        4
    xiaolvmu  
    OP
       Jan 6, 2015 via Android
    只好各自使用各自的重写规则了。
    # NEEDED BEGIN
    Options -Indexes
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(www.)?techllage.com$
    RewriteCond %{REQUEST_URI} !^/techllage/
    RewriteRule ^(.*)$ techllage/$1
    # NEEDED END




    # GZIP BEGIN
    <IfModule mod_deflate.c>
    SetOutputFilter DEFLATE
    AddOutputFilterByType DEFLATE text/css application/x-javascript
    </IfModule>
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 2 months"
    </IfModule>
    # GZIP END



    #BLOG BEGIN
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(www.)?xiaolvmu.techllage.com$
    RewriteCond %{REQUEST_URI} !^/xiaolvmu/
    RewriteRule ^(.*)$ /xiaolvmu/$1
    RewriteCond %{HTTP_HOST} ^(www.)?xiaolvmu.techllage.com$
    RewriteRule ^(/)?$ xiaolvmu/index.php [L]
    #BLOG END
    </Directory>

    <Directory "/var/www/html/techllage">

    # BEGIN Techllage Sub
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /techllage
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /techllage/index.php [L]
    RewriteCond %{HTTPS} !^on$ [NC]
    RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
    FileETag none
    </IfModule>
    # END Techllage Sub

    # ADD Techllage Sub
    # RULE BEGIN
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
    #RULE END
    # END ADD

    因为根目录下面的htaccess同样适用于二级目录,因此似乎只有这样了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6056 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 41ms · UTC 02:14 · PVG 10:14 · LAX 19:14 · JFK 22:14
    ♥ Do have faith in what you're doing.