How can I automatically redirect visitors of my website to its onion version if I detect that they're Tor users?
1 Answer
With 100% accuracy? You can't.
You can use tools like TorDNSEL and lookup each incoming user through a DNS query to discover if they're using a known Tor exit.
Alternatively you can use the TorBulkExitList to export the current set of relays that allow exiting to your service. This list will get stale though.
There are always being to be edge cases where an IP is no longer in use as a Tor exit but it is on the list and you would redirect them to the .onion and they wouldn't connect. Similarly there will be Tor users whose IP isn't on the list that you don't redirect.
Some other approaches, which are more accurate, would be to test in the browser itself if they can connect to .onion addresses. Putting a tag like <script src='http://foo.onion'>
and having the loaded script redirect users to the .onion website would let you redirect users who could fetch resources from the .onion but not those who couldn't.
Some Tor users choose to disable javascript entirely, in those cases you could take a similar approach but instead of javascript embed a CSS stylesheet that is loaded from the .onion site. If it is loaded, it could render a fullscreen overlay with a link for the user to click to take them to the .onion website.
-
Actually you can but don't know how. Recently i was searched phub with Google search same time orbot vpn mode was on. Google gave me results as normal. but when i click on those normal website site links its automatically opens phub onion website. i tried in different web browser but the same thing happened– arivCommented Sep 3, 2021 at 16:11