Author Topic: redirect error 302 instead of 404  (Read 10609 times)

0 Members and 1 Guest are viewing this topic.

Offline kanuharis

  • Newbie
  • *
  • Posts: 11
    • View Profile
redirect error 302 instead of 404
« on: December 05, 2011, 07:40:50 PM »
hi,
Recently I've lost all of my 4images gallery because of server crash. After re uploading and setting all things as before, I've got a serious problem. The deleted images which I've re uploaded has new url, so the old urls for same image redirect back to homepage. The problem is my webmaster tools account now showing more than 2000 duplicated title, discriptions etc. when I check old url, it is redirecting with "302 moved temporarily" code, which should be "404 not found". I've searched whole forum but no luck. Is there any way to redirect old images url to any custom error page, or redirect back to index page but with "404 not found". Please some one help on this matter.
Thanks and regards..
haris

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: redirect error 302 instead of 404
« Reply #1 on: December 06, 2011, 01:36:06 AM »
What type of "old" URL you are referring to?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline kanuharis

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: redirect error 302 instead of 404
« Reply #2 on: December 06, 2011, 10:16:29 AM »
attaching a screen shot directly from webmaster tools


Those second urls are old and redirecting to homepage with 302

Offline kanuharis

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: redirect error 302 instead of 404
« Reply #3 on: December 07, 2011, 02:59:42 PM »
Please help me somebody
at-least let me know where from this 302 error produced
regards

Offline mawenzi

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: redirect error 302 instead of 404
« Reply #4 on: December 07, 2011, 06:48:27 PM »
... your problem is caused by a i.m.o. unnecessary [Mod] Search Engine Friendly URLs or similar ...
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline kanuharis

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: redirect error 302 instead of 404
« Reply #5 on: December 07, 2011, 07:30:01 PM »
can you please explain. Should I have to remove SEF urls? that's bad :(
any other option?

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: redirect error 302 instead of 404
« Reply #6 on: December 08, 2011, 02:38:56 AM »
It's actually lack of feature in 4images or some might say it is a feature, you decide ;) - any errors it redirects to home page instead of showing an error message.

So here it is, show the error page with 404 header if something went wrong

In details.php find:
if (!check_permission("auth_viewcat"$cat_id) || !check_permission("auth_viewimage"$cat_id) || !$image_row) {

Insert above:
if (!$image_row)
{
	
header("HTTP/1.0 404 Not Found");
	
show_error_page($lang['image_error_404_not_found']);
}


In categories.php find:
if (!$cat_id || !isset($cat_cache[$cat_id]) || !check_permission("auth_viewcat"$cat_id)) {

Insert above:
if (!$cat_id || !isset($cat_cache[$cat_id]))
{
	
header("HTTP/1.0 404 Not Found");
	
show_error_page($lang['cat_error_404_not_found']);
}


In lang/<your language>/main.php at the end, above closing ?> insert:
$lang['image_error_404_not_found'] = "Error 404 - image not found";
$lang['cat_error_404_not_found'] = "Error 404 - category not found";
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline kanuharis

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: redirect error 302 instead of 404
« Reply #7 on: December 08, 2011, 05:54:12 PM »
thank you soooooo much :D
Now waiting for recrawl
could somebody make this post resolved
regards