0

I have the following .htaccess file.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)       /index.php/#/$1


</IfModule>

My intention is to support HTML5 mode for a AngularJS app that I am working on. This works fine and my URL redirections work as expected with the necessary changes in my AngularJS app.

However, I also wish to add the rewrite rule below to the .htaccess so that HTTP_AUTHORIZATION variable can be accessed in my PHP scripts.

RewriteEngine On
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]

How can I specify both these rules in the .htaccess file? Adding the second HTTP_AUTHORIZATION related line in the end of the <IfModule> section, breaks PHP from getting access to the Authorization headers from the PHP calls.

I am new to .htaccess and any help is appreciated..

2 Answers 2

2

So I figured this out.. The correct way to do this is..

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*)       /index.php/#/$1
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]

</IfModule>
Sign up to request clarification or add additional context in comments.

Comments

0

Sharath's answer did not work for me.
I did:

print_r($_SERVER);

and then found that the Bearer Token was hiding in :

$_SERVER['REDIRECT_HTTP_AUTHORIZATION']

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.