1

How can I grab the masked URL in PHP from the htaccess? I have already tried HTTP_HOST, REQUEST_URI and SERVER_NAME but it always returns .com when I am trying to grab the masked url being .nl in this instance. HTTP_REFERER is not reliable and doesn't always have anything to refer from.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.nl [NC]
RewriteRule ^(.*) http://domain.com/$1 [P] 
Nakul91
  • 1,245
  • 13
  • 30
jk1001
  • 13
  • 5

1 Answers1

1

PHP always sees the host under which it was called, which in your case alsways will be domain.com. However, a solution would be to include a query parameter in the rewritten URL, like:

RewriteRule ^(.*) http://domain.com/$1**?from=domain.nl** [P]

Depending on whether you may have a query-string in the incoming URL, you possibly will need two RewriteCond-RewriteRule Combinations, one starting the query-string with a question mark ? and one appending to it with an ampersand & if the question mark is already there.

syck
  • 2,984
  • 1
  • 13
  • 23
  • This is perfect. I wasn't sure how to add a querystring like that and that was the solution. Many thanks! – jk1001 Jul 10 '15 at 11:23