2012-06-23 20:06



So I want to do the following:

  1. if the user tries to go to an ypart of the site other than index.php, they get redirected to the https version.

  2. so if they try to go to they do not get redirected to the https version

  3. but if they go to any part of the site other than index.php (like welcome.php) they get redirected to the https version.

here's how I did full site https redirection before (I'm not sure how to do full site redirection to https example on index.php)

RewriteBase /
RewriteCond %{HTTP_HOST} ^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

RewriteCond %{HTTP_HOST} !^ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongpingwu8378 dongpingwu8378 9年前

    In order to have all pages except for index redirect to https, add the following to your .htaccess file:

    RewriteCond %{HTTPS} !on
    RewriteRule !^(index)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}

    You can add additional exceptions using the pipe character within the parenthesis, like so:

    RewriteRule !^(index|about|contact)\.php$ https://%{HTTP_HOST}%{REQUEST_URI}
    点赞 评论 复制链接分享