404 page for only a specific url

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
Jerry
 
 
Posts: 120
Joined: Fri Dec 02, 2016 10:13 am

404 page for only a specific url

Post 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
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: 404 page for only a specific url

Post 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
Best Regards, Adrian

Rogarema.net
Jerry
 
 
Posts: 120
Joined: Fri Dec 02, 2016 10:13 am

Re: 404 page for only a specific url

Post by Jerry »

Thank you.. I will try that
Jerry
 
 
Posts: 120
Joined: Fri Dec 02, 2016 10:13 am

Re: 404 page for only a specific url

Post by Jerry »

Adrian

I took a look but I think thats above my knowledge.
But thank you for helping me.

Jerry
WWBman
 
 
Posts: 916
Joined: Fri Jan 08, 2010 6:10 pm

Re: 404 page for only a specific url

Post 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?
Jerry
 
 
Posts: 120
Joined: Fri Dec 02, 2016 10:13 am

Re: 404 page for only a specific url

Post 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
WWBman
 
 
Posts: 916
Joined: Fri Jan 08, 2010 6:10 pm

Re: 404 page for only a specific url

Post by WWBman »

Have you created your own 404 page?
What would you want to do for Pinterest ones?
Jerry
 
 
Posts: 120
Joined: Fri Dec 02, 2016 10:13 am

Re: 404 page for only a specific url

Post by Jerry »

Yes I have.
I would like to create a different 404 page just for links just coming from pinterest
WWBman
 
 
Posts: 916
Joined: Fri Jan 08, 2010 6:10 pm

Re: 404 page for only a specific url

Post 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.
Jerry
 
 
Posts: 120
Joined: Fri Dec 02, 2016 10:13 am

Re: 404 page for only a specific url

Post 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
Adrian
 
 
Posts: 84
Joined: Tue Jun 13, 2017 4:44 pm

Re: 404 page for only a specific url

Post 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
Best Regards, Adrian

Rogarema.net
Post Reply