Search code examples
wordpressurlurl-rewritingmasking

Masking the URL - Wordpress


I have a question, is there a chance to write a script that will auto-mask URLs?

In my case it looks like this:

1) I insert the PP plug on my page, 2) Automatically download products whose links look like: outbounddomain.pl/offer/abc

Is there a chance to write such a script, which will automatically mask such links and convert the address to: mydomain.com/offer/abc -> when someone clicks on redirect it by redirecting 302 to the destination page.


Solution

  • You could probably do something like that with Pretty Links, it's able to automatically replace URLs, though I don't know how fine grained you can tune that.

    Are the outbound Links always following the same scheme? If so, you could just use whatever technique your Plugin allows to remove the outbound links domain from the content, so that instead of <a href="https://example.com/offer/abc"> it would be <a href="/offer/abc">.

    Redirecting /offer/abc/ to https://example.com/offer/abc/ then would be as simple as putting

    RewriteEngine On RewriteBase / RewriteRule ^(offer/.*)$ https://example.com/$1 [R=302,L]

    in your .htaccess. Make sure to put it before the Wordpress mod_rewrite part or WP will try to handle that request and throw a 404.