2012-11-09 4 views
-1

내 .htaccess 파일에서 다음을 사용하여 URL에 https없이 내 웹 사이트를 방문하는 모든 사용자에게 https를 적용합니다."www."를 삭제하십시오. url with forceful https

그러나 사용자가 https://www.mysite.co을 방문하면 요청에서 www를 삭제할 수 있기를 원합니다.

강제 https를 유지하면서 URL에서 www를 삭제하려면 .htaccess 파일에서 수정해야 할 내용을 알려주십시오.

감사합니다.

최대

+0

중복 : http://stackoverflow.com/questions/6399406/remove-www-from-https –

+0

이 게시물을 참조 ... 그것은 좋은 explaination에게있어 http://stackoverflow.com/questions/10725357/redirect-https-to-non-www-and-http-to-www/10726167 # 10726167 – Zak

+0

... 이미 가지고있는 자료가 중복되면 * 중복으로 * 서버 오류 백만개의 mo.d_rewrite 질문이 있고 당신의 중복 표적은 [우리]보다는 잘이었을 것입니다 (http://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite- 규칙 -하지만 두려워 -에 -)로 – voretaq7

답변

2

두 번 다시 쓰면됩니다.

RewriteEngine On 

RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://mysite.co/$1 [R,L] 

RewriteCond %{HTTPS} on 
RewriteCond %{HTTP_HOST} ^www\. [NC] 
RewriteRule ^(.*)$ https://mysite.co/$1 [R,L] 
+0

Zak과 aam1r에서 링크에 좋은 코멘트. – CoffeeMonster

+0

'www.mysite.co'를 할 때 작동하지만'https : // www.mysite.co'를 사용하지 않을 때 –

+0

내 실수 - http_host 대신 쿼리 문자열에서 일치했습니다. – CoffeeMonster