www제거 https로 접속.. 채택완료

Copy
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteBase /
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

사이트 접속시 www 제거하고 무조건 https로 들어오게 htaccess 파일을 이용해서 사용중입니다.

여기서 이런 질문하면 안될것 같은데요..

혹시 asp에선 위와 같이 적용하려면 어떤 파일 어떤식으로 표기를 해야 하나요.?

답변 4개

채택된 답변
+20 포인트
Copy
<%@ Language=VBScript %>
<%
If InStr(1, Request.ServerVariables("HTTP_HOST"), "www.", vbTextCompare) = 1 Then
    Dim redirectURL 
    redirectURL = "https://" & Mid(Request.ServerVariables("HTTP_HOST"), 5) & Request.ServerVariables("URL")
    Response.AddHeader "Location", redirectURL
End If
%>
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

https://www.happyjung.com/lecture/146

정리된 자료입니다.

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

asp는 IIS 웹서버에서 돌아가기 때문에 htaccess 파일을 사용할 수 없죠.

대신에 IIS에서 URL 재작성 모듈을 설치하고

web.config 파일에 리다이렉트 규칙을 작성해야 해야합니다.

따라서 URL 리디렉션 및 리라이팅을 지원하는 rewrite 모듈을 사용할 수 있습니다

<code> <rewrite> <rules> <rule name=“Remove WWW and force HTTPS” stopProcessing=“true”> <match url=“(.)" /> <conditions logicalGrouping=“MatchAny”> <add input=“{HTTP_HOST}” pattern="^www.(.)$” /> <add input=“{HTTPS}” pattern=“off” /> </conditions> <action type=“Redirect” url=“https://{C:1}/{R:1}” redirectType=“Permanent” /> </rule> </rules> </rewrite> </code>
 

아래 링크는 참고자료입니다.

ASP.NET 애플리케이션 구성 - ASP.NET | Microsoft Learn

HTTPS와 도메인의 www 리다이렉트 처리 | Blues Coder

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고