HTTP到HTTPS干净重定向

时间:2015-05-21 21:27:51

标签: .htaccess

我一直在网上和这个网站上搜索并遵循一些建议我设法让它一瘸一拐但它仍然不完美。

这是问题所在。当有人使用普通HTTP访问我的网站时,它会将其重定向到HTTPS,但网址看起来像https://www.domain.com/index.php?rewrite=1

这很难看,但这不是最重要的问题。问题是,当网站成员尝试登录时,在填写详细信息并单击登录后,页面将重新加载到https://www.domain.com/空白登录字段。再次输入信息并单击登录,成员可以在第二次尝试时登录。对于那些使用普通http访问网站的人来说,直到他们发现他们想要使用https而变得令人沮丧。

但是,我想解决这个问题,并请求你的帮助。

这是我当前的.htaccess文件,我知道有一些非常简单的变化,但我无法发现它。

谢谢!

IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On

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

  RewriteCond %{HTTP:X-Forwarded-Proto} =http
  RewriteCond %{HTTP_USER_AGENT} !(SEAOSEAPP)
  RewriteRule . https://%{HTTP:Host}%{REQUEST_URI} [L,R=permanent]

  # Get rid of index.php
  RewriteCond %{REQUEST_URI} /index\.php
  RewriteRule (.*) index.php?rewrite=2 [L,QSA]

  # Rewrite all directory-looking urls
  RewriteCond %{REQUEST_URI} /$
  RewriteRule (.*) index.php?rewrite=1 [L,QSA]

  # Try to route missing files
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} public\/ [OR]
  RewriteCond %{REQUEST_FILENAME} \.    (jpg|gif|png|ico|flv|htm|html|php|css|js)$
  RewriteRule . - [L]

  # If the file doesn't exist, rewrite to index
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?rewrite=1 [L,QSA]

</IfModule>

# sends requests /index.php/path/to/module/ to "index.php"
# AcceptPathInfo On

# @todo This may not be effective in some cases
FileETag Size

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml     text/css application/x-javascript application/javascript
</IfModule>

0 个答案:

没有答案