How to redirect old galley2 links to new zenphoto links

I hope someone with rewrite expertise can help me as I don't know how to do this - I don't want to lose my existing google index entries!

I have old gallery2 site with links that were `http://natureinfocus.com/galleries/fauna/insects/moths/adults/Luna_Moth_eye.jpg.html`

New link should be `http://natureinfocus.com/galleries/fauna/insects/moths/adults/Luna-Moth-eye.jpg.php`

So I tried adding in root .htaccess file:
`
Redirect 301 /galleries/fauna/insects/moths/adults/Luna_Moth_eye.jpg.html http://natureinfocus.com/galleries/fauna/insects/moths/adults/Luna-Moth-eye.jpg.php
`
which does at least let Google redirect the link, but now the link displayed on the page is:

http://natureinfocus.com/galleries/fauna/insects/moths/adults/Luna-Moth-eye.jpg.php?album=fauna/insects/moths/adults/Luna_Moth_eye.jpg.html

I'm thinking I should be using Rewrite Rule, but I don't have the knowledge on know how to write the rule - I've made some attempts but can't get it to work.

I'm asuming I should put the .htaccess in the root and not the zenphoto directory?

Could someone please give me an example for this file? Then I think I can fix the oher links.

I'm really struggling with this!

Comments

  • acrylian Administrator, Developer
    So the only difference is the `.html` instead the `.php`? Then you don't even need a rewrite rule. Just change the mod_rewrite suffix on Options > General > URL options

    Of course you would have to rename the image filename as well.
  • Unfortunately no. Underscores are now dashes. Also there are a few files that I will have to manually rename in any case.

    But good to know about the html/php choice. Is there any advantage of using php instead of html for suffix?

    Thanks for your quick reply - really worried about getting this resolved!
  • acrylian Administrator, Developer
    No advantage, just a default so that search engines know this is not a image file but a page.

    Any reasony why you did rename the images? I am sure there are surely tricks to replace the underscores with dashes in the url via htaccess using regular expressions. Don't have time to dig into that though
  • Right now, I am literally entering the new urls by hand as 301 redirects - I certainly don't expect you to get involved in file renaming issue, but as I said in first post, the redirected link is appearing as `http://natureinfocus.com/galleries/fauna/insects/moths/adults/Luna-Moth-eye.jpg.php?album=fauna/insects/moths/adults/Luna_Moth_eye.jpg.html` instead of `http://natureinfocus.com/galleries/fauna/insects/moths/adults/Luna-Moth-eye.jpg.php`

    I'm just trying to get rid of the extra stuff after the php? part in the new redirected link. Should I be making changes at the end of the zenphoto htaccess file instead of in the root htaccess?
  • acrylian Administrator, Developer
    That is a lot of work, I am sure there is an easier way. No, I think the redirect should be in the root of your domain but I have to admit I have never tried somehting like this.

    Maybe consult a specific htaccess forum?
  • After working with a htaccess guru, it appears that I need to add a rewrite rule to the htaccess file in the zenphoto (\galleries in my case) directory.

    As an example, he is advising:

    `
    RewriteEngine On
    RewriteBase /galleries

    RewriteRule ^fauna/insects/moths/adults/Luna_Moth_Eyes\.jpg\.html$ http://natureinfocus.com/galleries/fauna/insects/moths/adults/Luna-Moth-Eyes.jpg.php? [R=301,L]

    RewriteRule^admin/?$ zp-core/admin.php [R,L] ...
    `
    My question is, if I make these typs of changes (301 redirects for files that have been renamed or moved) to the htaccess file, do I need to run setup again? I didn't quite understand the instructions in the first few lines of the htaccess file.

    Thank you.
  • You will not need to run setup if you make the changes to the running version of the .htaccess file.

    But I am not exactly sure what change you are making. From what you have posted it would seem that all you need to do is change the `mod_rewrite suffix` to `.html` from `.php`. have you tried that? In other words it seems the only difference in the links is that the Gellery2 one ends in `.html` and your Zenphoto one currently ends in `.php`. But as I said, you can change that.
  • Changing from underscores to dashes and some files are just completely different names for various reasons. In some cases, I've relocated files to other albums and want Google to redirect to the new links.

    Strictly FYI, you may want to check
    for the discussion of this at `http://www.webmasterworld.com/apache/4211642.htm`. Go toward bottom of the thread to see their comments about the `RewriteRule^admin/?$ zp-core/admin.php [R,L]` rule.

    I will attempt their suggestions for my specific issue when I have a bit more time.
Sign In or Register to comment.