Skip to content
Advertisement

Keep query string for external urls

A user can be sent to the main website by some referral id, using a query string:

JavaScript

And when they click on a link to a login area, this query string must go with that external link:

JavaScript

I am working with wordpress, so I cannot append ?ref=<?php echo $_GET['ref']?> to that link.

I have already changed .htaccess to:

JavaScript

Every link back to the main website keeps the query strings, but external urls do not.

JavaScript

The QSA flag in htaccess should do the trick, but it’s not working for external links.

Advertisement

Answer

You can do this by adding this script at the end of your page. This code will pass variables to every links on client side.

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement