Page 1 of 1
404 page for only a specific url
Posted: Tue May 26, 2020 10:22 pm
by Jerry
I know this not a WB issue but I was hoping to pick the great minds who hang out here.
Does anyone know if there is a way to have 404 page specifically to only work from one URL?
I have our standard custom 404 which works well but I have too many 404 errors coming from Pinterest because there are pins coming from old information that is no longer on our site.
I know I could make redirects but that would almost impossible.
I know its a long shot.
Thank you in advance
Jerry
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 7:02 am
by Adrian
Hello Jerry,
if your server supports rewrite rules via htaccess, I think it should be possible to make this.
What to do in the htaccess?
If the referer is the "bad" url than go to "this" url, where "this url" is your "customised" 404 url.
Please search for "htaccess generators" that can make this.
That's the way I would do it.
Regards, Adrian
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 12:00 pm
by Jerry
Thank you.. I will try that
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 1:19 pm
by Jerry
Adrian
I took a look but I think thats above my knowledge.
But thank you for helping me.
Jerry
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 2:28 pm
by WWBman
Just curious but what would you want this to do?
Have you got one domain with many folders but some folders no longer exist?
If so, what would you want to do if anyone tries to access the missing folders?
Or do you just want to ignore all errors emanating from Pinterest?
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 5:40 pm
by Jerry
Thank you for replying.
I just wanted to create a Custom 404 just for broken links that come from Pinterest.
All other 404's would land on my current 404 page.
Thanks
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 5:47 pm
by WWBman
Have you created your own 404 page?
What would you want to do for Pinterest ones?
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 6:04 pm
by Jerry
Yes I have.
I would like to create a different 404 page just for links just coming from pinterest
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 8:12 pm
by WWBman
I too have very little knowledge of htaccess so I don't know if it's possible to have more that one 404 trap.
If you are familiar with php then there is a php variable $_SERVER['HTTP_REFERER'].
The server puts the referring url into this variable.
I
think it will contain
https://www.pinterest.com when a 404 comes from Pinterest.
Re: 404 page for only a specific url
Posted: Wed May 27, 2020 8:20 pm
by Jerry
Thanks
That is even more confusing to me.. lol
I was hoping there would be a simple solution but maybe not.
But thank you for your help
Re: 404 page for only a specific url
Posted: Thu May 28, 2020 6:42 am
by Adrian
Hello Jerry,
ok, let's trying this:
----Put this in yout htaccess
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://www\.pinterest\.com.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www\.pinterest\.com.*$ [NC,OR] //***
RewriteRule . /page.html? [L,R=302]
//*** this is just a comment, if you have just one URL you can remove it together with the [NC,OR] from the first line
This htacces code rewrite all the incoming Links from Pinterest to the new URL on your domain.
[L,R=3020] -> you can use also [L,R=301]
If you want to rewrite just some URL's from Pinterest, than you must specify them explicitly:
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^http://www\.pinterest\.com./xxx/yyy/pict.jpg [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www\.pinterest\.com./xxx/yyy/pict2.jpg [NC,OR]
RewriteRule . /page.html? [L,R=302]
That'S all.
Regards, Adrian