Rewrite 모듈, URL 재작성, https 설정 등이 돼 있는 상태에서다.
❚ .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
❚ nginx.conf
(server 블록 안)
location / {
return 301 https://example.com$request_uri;
}
❚ web.config
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="HTTP to HTTPs Redirect" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" ignoreCase="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType=""Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
❚ web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPS Forward All WEB APP</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
반응형
'코드' 카테고리의 다른 글
서브 도메인을 서브 디렉터리로 리디렉트 - web.config (0) | 2023.08.01 |
---|---|
서브 도메인을 서브 디렉터리로 리디렉트 - .htaccess (0) | 2023.07.31 |
URL redirect (0) | 2023.07.20 |
예)https://www.abc.co.kr -> https://abc.co.kr - 301 리디렉트2 (0) | 2023.07.17 |
예)https://www.abc.co.kr -> https://abc.co.kr - 301 리디렉트 (0) | 2023.07.15 |