본문 바로가기

webdesign/etc.

SSL certificate : Redirect

https://www.freecodecamp.org/news/how-to-redirect-http-to-https-using-htaccess/

 

How to redirect HTTP to HTTPS Using .htaccess

Chrome and Firefox have started showing insecure warnings on sites without SSL certificates. Without SSL, your website will show insecure to the visitors. Therefore, using an SSL-encrypted connection for safety, accessibility or PCI compliance reasons is n

www.freecodecamp.org

Redirect All Web Traffic  🌝 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
</IfModule>
블로그에서 설명한 코드 앞 뒤로 <IfModule mod_rewrite.c> ~ </IfModule> 붙여줘야함
그리고 수정한 .htaccess 파일을 index.html을 잡아주는 폴더 (ie. www/) 로 옮겨준다.
기존에 http://~ 로 시작하는 절대경로를 사용한 이미지들도 문제 없이 보여진다.

.htaccess  
 .htaccess 파일은 Apache 파일이므로 Apache 서버에서만 찾을 수 있습니다. link ( cafe24는 Apache 서버)

점으로 시작하는 파일 이름은 대개 숨겨진 파일입니다. 이는 일반적으로 기본적으로 표시되지 않음을 의미합니다.

이 파일을 보려면 FTP 클라이언트 또는 호스팅 파일 관리자에서 "숨김 파일 표시"를 설정하기 만하면됩니다

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{ENV:HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URl}/$1 [R,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

위의 소스를 적용할 경우, 기존에 http://~ 의 절대경로로 사용된 이미지들이 사파리에서 깨지는 현상 발생 (크롬에서는 제대로 보여짐)


'non-www' to 'www'

https://comodosslstore.com/resources/do-i-need-a-different-ssl-certificate-for-www-and-without/

 

Do I need a different SSL certificate for WWW and without (non-www)?

Get your SSL certificate from Comodo so it will cover both the www and non-www version of your website. You just need one Comodo certificate to secure your site with www and without.

comodosslstore.com

Almost all CAs can secure both WWW and non-WWW variations with a single certificate.

Apparently, cafe24 only covers 'www domain'.🤦🏻‍♀️ 

One of the easiest ways to get around this problem is to redirect your visitors from the non-WWW domain to the WWW version. Just use 301 redirects and you’ll be fine.  💆🏻‍♀️💆🏻‍♀️

 

 

https://www.a2hosting.com/kb/security/ssl/using-www-and-non-www-domains-with-an-ssl-certificate

The following lines demonstrate how to redirect visitors who enter a domain name without the www prefix to a secure connection. With these settings enabled on your web site, visitors who go to example.com or www.example.com (where example.com represents your domain) both obtain an SSL connection:

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

 

https://geekflare.com/redirect-non-www-to-www-non-www/

 

Redirect non-www to www or www to non-www

Redirecting requests from a non-preferred domain is important because search engines consider URLs with and without “www” as two different websites. It

geekflare.com