0

Am looking to by pass url based on value on header , when request coming to apache server will inspect the header and if value = test1

it will rewrite proxy pass url exampel :

www.demo.test.com  >> to 

www.end.test.com

if the value is null it will by pass the url to

www.null.test.com

what is the best way to test this case

LeoSam
  • 4,681
  • 8
  • 31
  • 40

1 Answers1

0

You can inspect HTTP headers with a RewriteCond, e.g.

RewriteCond %{HTTP:Some-Header} test1
RewriteRule ^ http://www.demo.test.com [L]

Based on the comments, when index.html is requested and a header Video: Provider1 is sent, rewrite to demo.test.com/provide1/m3u8.mp4. If the header is Video: Provider2, rewrite to demo.test.com/provide/m3u8.mp4

RewriteCond %{HTTP:Video} ^Provider1$
RewriteRule ^index.html$ http://demo.test.com/provide1/m3u8.mp4 [L]

RewriteCond %{HTTP:Video} ^Provider2$
RewriteRule ^index.html$ http://demo.test.com/provide/m3u8.mp4 [L]
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
  • I dont want to redirect the url itself , i want redirect specific "sub url" it will be request inside the code – LeoSam Nov 03 '14 at 08:12
  • I don't understand that. If you don't want to rewrite based on a HTTP header, what exactly is your requirement? – Olaf Dietsche Nov 03 '14 at 08:15
  • ill explain it in better way : – LeoSam Nov 03 '14 at 08:19
  • use connect to www.demo.com – LeoSam Nov 03 '14 at 08:19
  • ill request www.mysite.com/index.html Ive coustom headers value Video: Provider1 Or Video: Provider2 - If the value is Porvider 1 I want to : in js code in the html; there is url called demo.mysite.com i need it to re-wrtie and replaced by demo.test.com/provide1/m3u8.mp4 when ever its requested - If the value is Provider 2 I want to in js code in the html; there is url called demo.mysite.com i need it to re-wrtie and replaced by demo.test.com/provide/m3u8.mp4 when ever its requested – LeoSam Nov 04 '14 at 09:06
  • I don't understand the *: in js code in the html* part. But this is out of scope for Apache's mod_rewrite anyway. You should clarify and add this info to your question. In any case, please see updated answer. – Olaf Dietsche Nov 04 '14 at 11:11