Redirecting from a deleted album

dave_mck
dave_mck's picture

Joined: 2006-09-01
Posts: 11
Posted: Thu, 2012-04-12 01:43

I've deleted a few albums but bots and humans have bookmarked these old albums.

I tried adding a simple .htaccess line but I can't seem to get it to work. Am I missing something?

RedirectMatch 301 ^/gallery/v/OpenHouse/(.*) http://www.londonicedawgs.com/gallery/main.php
RedirectMatch 301 ^/gallery/v/BOWLING/(.*) http://www.londonicedawgs.com/gallery/main.php
RedirectMatch 301 ^/gallery/v/Coloring_Contest/(.*) http://www.londonicedawgs.com/gallery/main.php

Without the redirects, when someone goes to one of these deleted albums, they get:

Quote:
Error

Item not found.

Back to the Gallery
Error Detail -
Error (ERROR_MISSING_OBJECT) : Parent 7 path OpenHouse

in modules\core\classes\helpers\GalleryFileSystemEntityHelper_simple.class at line 98 (GalleryCoreApi::error)
in modules\core\classes\GalleryCoreApi.class at line 1952 (GalleryFileSystemEntityHelper_simple::fetchChildIdByPathComponent)
in modules\core\classes\helpers\GalleryFileSystemEntityHelper_simple.class at line 53 (GalleryCoreApi::fetchChildIdByPathComponent)
in modules\core\classes\GalleryCoreApi.class at line 1901 (GalleryFileSystemEntityHelper_simple::fetchItemIdByPath)
in modules\rewrite\classes\RewriteSimpleHelper.class at line 45 (GalleryCoreApi::fetchItemIdByPath)
in ??? at line 0 (RewriteSimpleHelper::loadItemIdFromPath)
in modules\rewrite\classes\RewriteUrlGenerator.class at line 103
in modules\rewrite\classes\parsers\modrewrite\ModRewriteUrlGenerator.class at line 56 (RewriteUrlGenerator::_onLoad)
in init.inc at line 170 (ModRewriteUrlGenerator::initNavigation)
in main.php at line 197
in main.php at line 104
in main.php at line 88
in main.php at line 3

System Information
Gallery version 2.3.1
PHP version 5.3.0 apache2handler
Webserver Apache/2.2.11 (Win32) PHP/5.3.0
Database mysqli 5.1.36-community-log
Toolkits ImageMagick
Operating system Windows NT SERVER 5.0 build 2195 (Windows 2000 Professional Service Pack 4) i586
Browser Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20100101 Firefox/11.0

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2012-04-12 02:34
Quote:
Without the redirects, when someone goes to one of these deleted albums, they get:

actually anonymous users get a more generic error w/out all the details.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2012-04-12 02:44

you may want to redirect in the errorpage
/modules/core/templates/ErrorPage.tpl
line ~65 something like:

{if !$ErrorPage.isAdmin}
<script>document.location.href='{g->url}';</script>
{/if}

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dave_mck
dave_mck's picture

Joined: 2006-09-01
Posts: 11
Posted: Thu, 2012-04-12 02:45

That is right, I forgot I was logged in when I was testing it out but it still generates an error, Why not toss it back to the main page?

 
dave_mck
dave_mck's picture

Joined: 2006-09-01
Posts: 11
Posted: Thu, 2012-04-12 02:58

The referrer is a bit messy but it works but I would like a proper 301 redirect so bots stop filling my error logs trying to hammer old albums.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2012-04-12 03:07

would this work better?

    {if !$ErrorPage.isAdmin}
        {php} header("Location: /gallery/main.php", true, 301) {/php}
    {/if}

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dave_mck
dave_mck's picture

Joined: 2006-09-01
Posts: 11
Posted: Thu, 2012-04-12 04:30

Weird, it worked a couple times now it's not.
I'm also getting php errors in my error log.

Quote:
[12-Apr-2012 00:15:29] PHP Warning: Cannot modify header information - headers already sent by (output started at X:\LID\------error.tpl.php:6) in X:\LID\------ErrorPage.tpl.php on line 96

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2012-04-12 05:15

yea, I would do this myself:: move the condition to the top of the page as so there is no output before:

{if isset($ErrorPage.code.missingObject) && !$ErrorPage.isAdmin}
    {php} header("Location: /gallery/main.php", true, 301) {/php}
{/if}

you can remove the isAdmin check if you don't care to catch these yourself.

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
dave_mck
dave_mck's picture

Joined: 2006-09-01
Posts: 11
Posted: Thu, 2012-04-12 15:36

I tried it at the top last night too but still got "headers already sent"
Don't suppose I could add this to whatever file contains the header. Get it in before the header is sent.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2012-04-12 16:00

look in modules/core/ErrorPage.inc for setResponseHeader

-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2

 
Dayo

Joined: 2005-11-04
Posts: 1642
Posted: Thu, 2012-04-12 16:23

I'll handle this along the track you were following before ... as a redirect and avoid editing the core files if possible.

Some points:

1. What exactly did you mean by not being able to get the redirect to work?
2. Where in your htaccess did you place the lines?
3. Can you paste a copy of the htaccess?
4. Try adding a "[L]" or "[QSA, L]" after each line

--
dakanji.com