OpenSource

[Apache] Redirect url

아르비스 2016. 11. 25. 13:26

URL의 변경 혹은 Redirect가 필요한경우

아래와 같이 설정하면 쉽게 DNS변경 분을 적용할 수 있다.


단 HTTPS  (ssl/tls) 인 경우, 인증서를 통과한 후에 처리해야 에러가 없다.

인증서 이전에 적용하면 에러남..


 

RewriteEngine On

RewriteRule ^(.*)$ https://stg.efss.xxxx.net$1 [R,L]



SSL 인증을 태우지 않으면 에러난다.


Virtual Host인 경우 아래와 같이 적용

<VirtualHost *:443>

  DocumentRoot /ccpkg/platform/apache/htdocs

  ServerName stage.xxxx.net:443


SSLEngine on


SSLCertificateFile "/ccpkg/platform/apache/conf/cert/prd/cert.pem"

SSLCertificateKeyFile "/ccpkg/platform/apache/conf/cert/prd/efss.key.pem"

SSLCACertificateFile "/ccpkg/platform/apache/conf/cert/prd/Thawte-WildCard-Chain-sha2.pem"


ErrorLog "| /ccpkg/platform/apache/bin/cronolog /ccdata/logs/platform/apache/%Y%m/stage_ssl_error.log.%Y%m%d"

TransferLog "| /ccpkg/platform/apache/bin/cronolog /ccdata/logs/platform/apache/%Y%m/stage_ssl_access.log.%Y%m%d"


CustomLog "| /ccpkg/platform/apache/bin/cronolog /ccdata/logs/platform/apache/%Y%m/stage_ssl_request_log.%Y%m%d" \

          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"


<FilesMatch "\.(cgi|shtml|phtml|php)$">

    SSLOptions +StdEnvVars

</FilesMatch>

<Directory "/ccpkg/platform/apache/cgi-bin">

    SSLOptions +StdEnvVars

</Directory>


RewriteEngine On

RewriteRule ^(.*)$ https://stg.efss.xxxx.net$1 [R,L]


# 이하 제거

#Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
#Header always edit Set-Cookie (.*) "$1; HTTPOnly; Secure"
#Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"

#제거

</VirtualHost>