Web Server Domain Redirect or HTTP Redirect SSL

剛好最近有客戶詢問Web Server如何做到Domain redirect,順便也把HTTP redirect SSL寫進去好了

1. Redirect 301 與302差別
2. Apache Redirect
3. Barracuda Load balancer ADC Redirect

1. Redirect 301 與302差別

對於使用者而言 Redirect 301與302 其實是完全沒差的,但是對於搜尋引擎則是有差異的
301
永久重新導向 (Permanently Redirect) 
搜尋引擎會記住新網址,這樣使用者透過搜尋引擎時,則就會直接連入新網址。
302
暫時重新導向 (Temporary Redirect)
搜尋引擎會記住新網址,但如果網站不是永久更換網址時,則原有網址搜尋排名則會降低。
2. Apache Redirect
編輯httpd 設定檔案
設定http://www.test.com  Permanently Redirect(301)  https://site1.chmost.com/

#vi /etc/httpd/conf.d/site1.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.test.com
Redirect permanent / https://site1.chmost.com/
</VirtualHost>

NameVirtualHost *:443
<VirtualHost *:443>
  # Because this virtual host is defined first, it will
  # be used as the default if the hostname is not received
  # in the SSL handshake, e.g. if the browser doesn't support
  # SNI.
  DocumentRoot /var/www/site1
  ServerName site1.chmost.com
  SSLEngine on
  SSLCertificateFile /etc/pki/tls/certs/site1.crt
  SSLCertificateKeyFile /etc/pki/tls/private/site1.key

</VirtualHost>

重新啟動httpd服務

#/etc/init.d/httpd restart

3. Barracuda Load balancer ADC Redirect
Traffic >> WebSite Translations >> REDIRECT RULES >> Add Rule

URL ACL Name
Domain Redirect
Enable ACL
Yes
Host Match
www.test.com
URL Match
/*
Extended Match
*
Extended Match Sequence
1
Action
Permanent Redirect
Redirect URL
http://site1.chmost.com/

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Refer:
https://wiki.apache.org/httpd/RedirectSSL
https://techlib.barracuda.com/display/BLBv42/Understanding+Redirect+Rules

Facebook Comments