1

I want to add a non-parameter canonical link to all parametrized URLs. I try to do this on the following way:

<IfModule mod_rewrite.c>

### Catching all URLs with non-empty parameter ###
    RewriteCond %{QUERY_STRING} . 

### Adding to all parametrized URLs an environment variable ###
    RewriteRule .* : [E=MY_HEAD:1]

</IfModule>

<IfModule mod_headers.c>

### Setting a non-parametrized URL as canonical to all URLs with an environment variable
    Header set Link '%{HTTP_HOST}%{REQUEST_URI}e; rel="canonical"' env=MY_HEAD

</IfModule>

My question is: looking for examples i found results with and without the e after {REQUEST_URI}. What means this e in this context?

Evgeniy
  • 2,337
  • 2
  • 28
  • 68

2 Answers2

2

The e is the syntax used by mod_headers to reference an environmental variable:

https://httpd.apache.org/docs/current/mod/mod_headers.html#Header

%{VARNAME}e The contents of the environment variable VARNAME.


Note: I know this is old, but I had the same question and the PHP answer is of no relevance to htaccess.

chris
  • 3,019
  • 23
  • 21
1

The e Regex Modifier in PHP.

The e modifier is a deprecated regex modifier which allows you to use PHP code within your regular expression. This means that whatever you parse in will be evaluated as a part of your program.

and also you can refer this

Harsh Shah
  • 1,386
  • 14
  • 19
  • Does it mean, that this code doesn't work without the `e` and examples without it are erroneous? – Evgeniy Dec 05 '18 at 15:39