Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does this this HTTP Authorization RewriteRule do?

I have an rewrite recursion error somewhere on my website that Google Bot caused, but I can't find the url that caused it because my Loglevel is low. I raised it but it has not happened again so far.

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 

All Rewriterules look fine to me and have the [L] flag, except this one.

I can't quite understand it. It is from the open source shop system Magento.

As far as I can tell it does nothing but sets the environment variable E. But isn't that a very stupid way of doing that? Shouldn't you use SetEnv if that was the goal?

like image 264
The Surrican Avatar asked Feb 09 '11 16:02

The Surrican


People also ask

What is Apache RewriteRule?

RewriteRule specifies the directive. pattern is a regular expression that matches the desired string from the URL, which is what the viewer types in the browser. substitution is the path to the actual URL, i.e. the path of the file Apache servers. flags are optional parameters that can modify how the rule works.

What does IfModule mod_rewrite C mean?

The <IfModule mod_rewrite. c>... </IfModule> block ensures that everything contained within that block is taken only into account if the mod_rewrite module is loaded. Otherwise you will either face a server error or all requests for URL rewriting will be ignored.

What is RewriteCond in htaccess?

htaccess rewrite rules can be used to direct requests for one subdirectory to a different location, such as an alternative subdirectory or even the domain root. In this example, requests to http://mydomain.com/folder1/ will be automatically redirected to http://mydomain.com/folder2/.

What is rewrite base?

RewriteBase is a useful server directive available for Apache web server that allows you to easily update numerous rewrite rules at one go.


1 Answers

Symfony developers Group has a good answer for it. I quote:

it looks like your hosting is running php as a fcgi, not a php5_module, like your localhost does. ( phpinfo - Server API: CGI/FastCGI )

the point is that php5_module automatically handles HTTP_AUTHORIZATION headers, but fcgi_module does not.

solution is simple - add this line to your .htacces on your hosting server:

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

It worked for me

like image 90
Etienne Marais Avatar answered Sep 22 '22 18:09

Etienne Marais