子域不使用https

时间:2017-05-27 10:24:15

标签: php .htaccess codeigniter ssl

发布通配符SSL,但仍无法将https与子域一起使用。

主域名与http和https都正常,但子域只适用于http

  

和https:// {subdomain}。{domain} .com 生成404错误

.htaccess代码是:

<IfModule mod_rewrite.c>
    RewriteEngine on

    # Turn on HTTPS
    RewriteCond %{HTTPS} on
    RewriteRule (.*) https://subdomain.domain.com?/$1 [L,QSA]

    RewriteRule ^([a-z0-9_-]+)\.html$ index.php/page/$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|asset|robots\.txt)
    RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]
</IfModule>
  • 在linux中使用Apache。
  • 主域名在PHP Wordpress中。
  • 子域名在PHP Codeigniter MVC中。

提前致谢!

1 个答案:

答案 0 :(得分:0)

# Turn on HTTPS
RewriteCond %{HTTPS} on
RewriteRule (.*) https://subdomain.domain.com?/$1 [L,QSA]

您的“强制HTTPS”指令无效。这看起来可能会导致404(否则,它会导致重定向循环)。上述指令将请求重定向到查询字符串,清除URL路径。 ?看起来错位了。 (顺便说一下,这与你在下面的重写中所做的类似 - 但这是非常不同的。)

暂时尝试完全删除这些指令。你还得到404吗?

上面应该写成:

RewriteCond %{HTTPS} !on
RewriteRule (.*) https://subdomain.domain.com/$1 [R,L]

(仅当您确定它正常工作时才将R更改为R=301。)

RewriteRule ^([a-z0-9_-]+)\.html$ index.php/page/$1 [L]
:
RewriteRule ^(.*)$ ./index.php?/$1 [L,QSA]

旁白:这些重写也不一致。第一个使用路径信息在内部重写。第二个重写为查询字符串。你应该做其中一个,而不是两个(除非这是两个不同系统的混搭)?

相关问题