2

I would like all links and address bar entries in the pattern https://*.wikipedia.org/* to be redirected to https://*.0wikipedia.org/*

I tried to achieve this by adding these entries to /etc/hosts file, but it didn't work:

0wikipedia.org  wikipedia.org
en.0wikipedia.org   en.wikipedia.org

Any suggestions please?

1 Answer 1

3

Yes it is, but it's not the best way. I would look into browser extensions for redirecting requests.


Here is how to do it on the network layer: You need to use a hosts file with one entry per subdomain (or a dns-server with wildcards), like this:

127.0.0.1 en.wikipedia.org

Then you run a webserver on localhost, which redirects all accesses to en.wikipedia.org to en.0wikipedia.org/ while preserving the path. This can be done for example with mod_rewrite for apache.

Direct redirect per hosts file is not working, as the hosts file has nothing to do with redirecting anything, but is just a basic form of name resolution mechanism. The solution above just uses this to fake that en.wikipedia.org is served from your computer and then redirects the access to your webserver to the target url.

Further you need to have a certificate on the server as the urls use https, which needs to have an security exception in your browser, because it is either self-signed or for another domain as you won't get a certificate for the wikipedia domain from any certificate authority which is in your browsers certificate store.


So while it is possible, it is quite complicated especially because of the https part.

Thanks to @TheFiddlerWins for pointing out the problem with https.

4
  • 1
    Please note that since it's an HTTPS URL you'll need to have certificates that match the new URL for everything to work properly. Oct 12, 2017 at 13:14
  • 1
    Indeed. So it's probably a way better idea to implement it on browser layer. I guess firefox has quite a few addons which allow to redirect requests. Have a look at their addon site as I would have to research them myself.
    – allo
    Oct 12, 2017 at 13:26
  • Thanks! I'll have a look at browser addons/extensions. But I guess achieving this simply via hosts file could be possible if I knew the IP addresses of `en.0wikipedia.org´ and the like, is that right?
    – Sadi
    Oct 12, 2017 at 15:09
  • No. Only via hosts is only possible for servers configured in a very specific way and not using https. As most hosts serve data based on the domain name you're using, en.0wikipedia.org would just give you an error (or blank page) when used with another domain name.
    – allo
    Oct 16, 2017 at 13:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .