htaccess redirect 4 specific pages to https

前端 未结 2 922
礼貌的吻别
礼貌的吻别 2021-01-05 09:35

I have a problem where I need to redirect 4 specific pages on my website to their https secure versions.

I currently have an htaccess file which is redirecting both

2条回答
  •  情书的邮戳
    2021-01-05 09:58

    Options +FollowSymlinks
    RewriteEngine On
    RewriteBase /
    
    #redirect www.mydomain.com to mydomain.com (or any other subdomain)
    RewriteCond %{HTTP_HOST} !^mydomain.com$ [NC]
    RewriteRule ^(.*)$ http://mydomain.com/$1 [L,R=301]
    
    #force https for certain pages    
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(page1\.php|page2\.php|page3\.php|page4\.php)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
    

提交回复
热议问题