Rscrub's default behavior is to only scrub referrer information when requested. Optionally, rscrub can act on all links.
93 | 94 | 132 |Note: There is a problem of having no preview and no identifying information appear when posting scrubbed links to certain social media sites. This problem can be addressed: if the Snapshot Visual Preview plugin is installed, properly configured, and enabled, then Rscrub will provide a snapshot preview and the proper headers to these sites automatically. Please see the Snapshot project page on github for more information.
133 |Rscrub can use subdomains to scrub urls, this requires access to your Virtual Host config files and important additions to the YOURLS .htaccess
file. When using this option the prefix settings are still relevant.
If you are using a subdomain for pass-through scrubbing of long url's, please set the options below. Prefix options are still relevant.
144 |Note that this will change many values in the Tools dialogue, and it will make some important changes to rscrub.js
.
To use a subdomain for a prefix function, we first need to add it in to the YOURLS virtual host conf file in Apache using the ServerAlias
directive. Your conf file should look something like the following.
175 | <VirtualHost *:80> 176 | 177 | ServerName $h 178 | 179 | ServerAlias $o[6].$h 180 | 181 | DocumentRoot /var/www/YOURLS/ 182 | <Directory /var/www/YOURLS/> 183 | Options -Indexes +FollowSymLinks +MultiViews 184 | AllowOverride All 185 | Order allow,deny 186 | allow from all 187 | </Directory> 188 | 189 | # Possible values include: debug, info, notice, warn, error, crit, 190 | # alert, emerg. 191 | LogLevel info 192 | ErrorLog /var/log/apache2/error.log 193 | CustomLog /var/log/apache2/access.log combined 194 | 195 | </VirtualHost> 196 |197 |
You might find your Apache default virtual host config file at /etc/apache2/sites-available/000-default.conf
.
Once you have added that in, make sure to save the file and restart Apache.
199 | 200 |The following rules need to be added in to the very top of the YOURLS .htaccess file. They make use of both mod_rewrite
and mod_proxy
, so both of these modules need to be enabled on your server.
203 |
204 |
205 | RewriteEngine On
206 |
207 | # RSCRUB - SHORT URL
208 | RewriteCond %{HTTP_HOST} ^$o[6]\.$ [NC]
209 | RewriteCond %{REQUEST_URI} !^https?://.* [NC]
210 | RewriteRule ^(.*)$ https://$h/$o[1]$1 [P]
211 |
212 | # RSCRUB - LONG URL
213 | RewriteCond %{HTTP_HOST} ^$o[6]\.$ [NC]
214 | RewriteRule ^(https?://?)(.*)$ https://$h/$o[3]$2 [P]
215 |
216 |
217 |
218 | These rules have been generated using this site's current configuration. Any changes to your setup will necessitate an alteration of these rules in your system.
219 |NOTE: If you are using SSL on your site, which is reccomended for this module, make certain to set SSLProxyEngine on
in your virtual host, otherwise these proxies will fail. If not, you will have to adjust the above code accordingly.
You can enforce scrubbing for every link on a page or site. This solution has two parts.
228 | 229 |Place this in your html just above the </body>
tag. If applicable, it can be put into footer.php
. Note: Any link that appears after this code is called will not be scrubbed.
234 | <script src="https://$h/io/rscrub.js?v=$v"></script> 235 | <script type='text/javascript'><!-- 236 | protected_links = 'example.com,$h'; 237 | auto_anonymize(); 238 | //--></script> 239 |240 | 241 |
In the above example, any link that belongs to the example.com
or $h
domains will be left unscrubbed. Adjust to suit.
The client side code calls the script rscrub.js
, which first has to be configured here and then downloaded to your server. The above example places it at $h/io
, so the foler io
needs to be created in the YOURLS root folder.
There are a few ways that client applications or pages may connect to rscrub. Here is a non-exhaustive list of examples of how this might be done.
278 |Note: These examples have been pre-formatted to work with this (your) site, and are therefore copypasta ready.
279 | 280 |If you only need to scrub a single link, just wrap the "prefix + url" in html and post it on your site.
283 | 284 |285 | <a href='https://$urlhttps://www.whatismyreferer.com'>Your Text Here</a> 286 |287 | 288 |
PHP can be used to create a link scrubbing shorthand.
291 |First place this function on your page.
292 | 293 |294 | <?php 295 | function hideref($strUrl='', $text='') { 296 | $a= "https://$url".$strUrl; 297 | $b= "<a href='$a' target='_blank'>$text</a>"; 298 | return $b; 299 | } 300 | ?> 301 |302 | 303 |
Then just use this shorthand to scrub links.
304 | 305 |306 | <?= hideref('https://www.whatismyreferer.com', 'PHP Link Text') ?> 307 |308 | 309 |
Similarly, we can use a javascript function to shorten links.
312 |Here the function must appear above whatever link you want to use it on.
313 | 314 |315 | <script language="JavaScript"> 316 | function hideref(strUrl){ 317 | return "https://$url"+escape(strUrl); 318 | } 319 | </script> 320 |321 | 322 |
Here's the "shorthand"
323 | 324 |325 | <a href="https://www.whatismyreferer.com" onclick="window.open(href=hideref(this.href)); return false;">JS Link Text</a> 326 |327 | 328 |
Current total number of rscrub pass-through events: $o[3]
332 |Date of last counter reset: $o[4], UTC
333 | 334 | 344 |