Fix the AddThis 404s on the Facebook iOS App – rewrite %23 to #

If you use the AddThis sharing plugin, you may incur in a problem: the iOS Facebook app will sometimes redirect shared links to http://example.com/%23.VVMxmH6d8SY.facebook instead of http://example.com/#.VVMxmH6d8SY.facebook as it should.

This known issue break the link, and directs the user to a 404, or “Page Not Found”, wasting that precious social traffic.

If your site is running on an nginx webserver, here is the solution.

Log in as root to your server’s SSH, and enter the following command, changing the part in red to your website’s URL:

sudo nano /etc/nginx/sites-available/example.com

You should see something like this,

server {
    listen 80;
    listen [::]:80;

    root /var/www/example.com/html;
    index index.html index.htm;

    server_name example.com www.example.com;

    location / {
        try_files $uri $uri/ =404;
    }
}

Now, what you should do is add the following line inside the “server” brackets

rewrite ^(.*)\#(.*)$$1#$2 redirect;

 

Thus, you will have the following config:

server {
    listen 80;
    listen [::]:80;

    root /var/www/example.com/html;
    index index.html index.htm;

    server_name example.com www.example.com;
    rewrite ^(.*)\#(.*)$$1#$2 redirect;

    location / {
        try_files $uri $uri/ =404;
    }
}

Now, all you have to do is press “esc”, and Ctrl + X to exit. It will ask you if you wanna save the changes. Press Y and then ENTER to confirm the filename (which is your URL, in this case example.com)

Rebuild your cache and now everything should work as intended.

Hope this was helpful!