1

The task is to get referer domain and send it to my script by RewriteRule. My decision is

SetEnvIf Referer "^https?://(.*)/" myref=$1
RewriteRule ^(.*)$ script.php?referer=%{ENV:myref}

It works right but I wonder if there are any ways to do it (perhaps with RewriteCond)?

chaika_sv
  • 384
  • 1
  • 4
  • 16

1 Answers1

0

mod_rewrite has a variable named %{HTTP_REFERER}. It contains what you expect. You can use it like this:

RewriteCond %{REQUEST_URI} !^/script\.php$
RewriteRule ^ script.php?referer=%{HTTP_REFERER} [L]

See the documentation for more information.

Sumurai8
  • 20,333
  • 11
  • 66
  • 100