Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:config:internal-redirect [2018/09/27 21:03]
Jackson Zhang
litespeed_wiki:config:internal-redirect [2018/09/27 21:10]
Jackson Zhang [Internal Redirect]
Line 1: Line 1:
 ====== Internal Redirect ====== ====== Internal Redirect ======
  
-Web server internal redirect via backend response header, aka X-Sendfile or X-Accel-Redirect,​ is a feature used by some web backend developers and popularized by Ruby on Rails. LSWS and OLS use a simple header "​X-LiteSpeed-Location"​ to achieve the same goal.+Web server internal redirect via backend response header, aka X-Sendfile or X-Accel-Redirect,​ is a feature used by some web backend developers and popularized by Ruby on Rails. LSWS and OLS use a simple header ​"​Location"​ or "​X-LiteSpeed-Location"​ to achieve the same goal.
  
 ===== What is this internal redirect via response header? ===== ===== What is this internal redirect via response header? =====
Line 15: Line 15:
 To get this to work on LiteSpeed, just use a simple header "​X-LiteSpeed-Location"​ in your php script. To get this to work on LiteSpeed, just use a simple header "​X-LiteSpeed-Location"​ in your php script.
  
-==== Set header "X-LiteSpeed-Location"​ in your php script ====+==== Set header "​Location"​ in your php script ====
  
-In the return responsefollow ​the directions below:+Set "​**Location**"​ header pointing to a URL without ''<​nowiki>​http://​domain</​nowiki>''​just the URL without the hostname part. Do not set a "​**Status**"​ header in response. Make sure no "​Status"​ header is returned. PHP always adds "​**Status**"​ header automatically when a "​**Location**"​ header was set.
  
-  ​- Return a normal "​**Location**" ​header ​without ​''<​nowiki>​http://​domain</​nowiki>'',​ just the URL without the hostname part. Do not set a "​**Status**" ​header ​in response. Make sure no "Status"​ header is returned. PHP always adds "​**Status**"​ header automatically when a "**Location**" ​header was set. +  ​<?php 
-  ​- ​Add a special header "​**X-LiteSpeed-Location**"​ starting from LSWS 3.0.2 to address this, just use it in the same way as a "​**Location**"​ header. For example, just put a line like below to the php script:+  ​header('Location: /php-icon.png'​);​ 
 +  ?> 
 + 
 +==== Set header "X-LiteSpeed-Location" ​in your php script ==== 
 +Add a special header "​**X-LiteSpeed-Location**"​ starting from LSWS 3.0.2 to address this, just use it in the same way as a "​**Location**"​ header. For example, just put a line like below to the php script:
  
   header('​X-LiteSpeed-Location:​ /​path/​to/​file_to_be_redirected'​);​   header('​X-LiteSpeed-Location:​ /​path/​to/​file_to_be_redirected'​);​
  • Admin
  • Last modified: 2018/09/28 15:42
  • by Lisa Clarke