Title: Is it possible to modify an incoming request's header?
Tags: php;apache;laravel-5
Question: I have a laravel php framework set up, I want to set some header to all incoming requests so my framework's plugin can find it in the header.
Is it possible to modify incoming request's header?
I tried this but it didn't modify the request header.
$_SERVER['HTTP_AUTHORIZATION'] = "Bearer xxx";
echo Request75b5:f2c1:f5d7:b954:8dc3:cee9:baf:a8c0header("Authorization"); // "" (ie., it displays nothing)
Comment: I know that this is not good practice, but as a quick fix, I need to set authorization header to all incoming requests.


Here is another answer: The application is not the place to deal with HTTP headers. It should be done with web server. Try mod_headers.
This module provides directives to control and modify HTTP request and response headers. Headers can be merged, replaced or removed. In your case
Header set MyHeader "Authorization"

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:12/12/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<php><apache><laravel-5>', 'Title': "Is it possible to modify an incoming request's header?", 'ViewCount': 356, 'id': 34237272, 'user_AboutMe': '<p>~10 years of experience building top quality applications (Web apps, Backend Systems &amp; Mobile apps) from scratch.</p>\n<p>Expert in <code>iOS Swift</code> &amp; <code>Node.JS</code></p>\n<p><strong>Most recent work:</strong></p>\n<blockquote>\n<p>Koo -&gt; <a href="https://apps.apple.com/us/app/id1515425674" rel="nofollow noreferrer">https://apps.apple.com/us/app/id1515425674</a></p>\n</blockquote>\n<blockquote>\n<p>ONE Championship -&gt; <a href="https://apps.apple.com/us/app/id1351178131" rel="nofollow noreferrer">https://apps.apple.com/us/app/id1351178131</a></p>\n</blockquote>\n<blockquote>\n<p><a href="https://scroll.in/" rel="nofollow noreferrer">Scroll News</a>, <a href="https://www.scoopwhoop.com/" rel="nofollow noreferrer">ScoopWhoop</a>, <a href="https://www.wickedride.com/" rel="nofollow noreferrer">WickedRide</a> etc in the past</p>\n</blockquote>\n', 'user_AccountId': 1187822.0, 'user_DisplayName': 'Nagendra Rao', 'user_Reputation': 6816.0, 'user_Views': 666.0, 'user_id': 1161412.0}}