301 Rewrite role changing folder names and image page exension

Hello.

A friend of mine has changed folder names (not title, but actual folder names) and mod_rewrite suffix from standard ".php" to ".html"
Original folder names had SAME "-gallery-suffix" at end of its name.

For example:

http://www.example-site-name.com/my-pets-gallery-suffix/dogs-gallery-suffix/
http://www.example-site-name.com/my-pets-gallery-suffix/dogs-gallery-suffix/image-name.jpg.php

Now it is without that "-gallery-suffix" and ".html" instead of ".php" like this:

http://www.example-site-name.com/my-pets/dogs/
http://www.example-site-name.com/my-pets/dogs/image-name.jpg.html

I need help with 301 redirection, I tried this:
`

#Image pages

RewriteRule ^-gallery-suffix(.*).jpg.php(.*)$ $1.jpg.html$2 [L,R=301]

# Folder pages

RewriteRule ^-gallery-suffix(.*)$ $1 [L,R=301]

`

It works great, for first folder level:

http://www.example-site-name.com/my-pets/
http://www.example-site-name.com/my-pets/image-name.jpg.html

But, for multi level galleries with sub-folders it just remove last "-gallery-suffix" and I get this:

http://www.example-site-name.com/my-pets-gallery-suffix/dogs/
http://www.example-site-name.com/my-pets-gallery-suffix/dogs/image-name.jpg.html

How to remove all instance of "-gallery-suffix" if more than one if URL?

Could you please fix my rewrite roles?

Best regards.

Comments

  • acrylian Administrator, Developer
    http://www.example-site-name.com/my-pets/
    http://www.example-site-name.com/my-pets/image-name.jpg.html

    That are the modrewrite based links how Zenphoto generates them. There was never a "suffix" on album names, why should they… If you - for reasons I admit I don't understand - need something appended to the folder names just rename the folders. No need for rewrite rules.

    Sorry, we can't fix your special rewrite rules for you.
  • Real folder names were like this:

    Folder title "Animals", folder name on disk "animals-my-photographs".

    Sub-folder title "My pets", folder name on disk "my-pets-my-photographs".

    I do not know why, but user renamed most folder names during creation using same pattern (adding "-my-photographs" at end).

    Now folder names are renamed and url is cleaner without that "-my-photographs", and everything is working well.

    I need rewrite rules for .htaccess before any ZenPhoto work to redirect any visitor who wish to access bookmarked page, or to follow link from other sites, and to tell search engines that content is moved to another address. All pages were indexed with old urls (ZenPhoto use urls for categories same as folder names on disk), content is same, just URL is little shorter, without that "-my-photographs", so, old urls are now 404.

    I hope now you understand why that 301 redirection is needed?
  • This really is not the forum for your question on rewrite rules. Probably you should start here http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
  • acrylian Administrator, Developer
    Ok, now I get it.

    The non rewrite link of an album is
    `index.php?album=my-pets`
    If it is a subalbum of "animals" it would be
    `index.php?album=animals/my-pets`

    I fear this will not be easy as the actual rewriting is handled internally with Zenphoto now and not via htaccess directly. Maybe my collegue has any idea, I am really no htacess wizard for such specific things (it is not directly a ZP issue technically).
  • Yes, it is not directly a ZP issue technically, ZP is working perfectly, I just need way to tell my server this.

    If someone wish to open old url:

    http://www.example-site-name.com/animals-my-photographs/my-pets-my-photographs/

    rewrite it to

    http://www.example-site-name.com/animals/my-pets/

    that is now url and ZenPhoto will do rest as usually.

    I thought that .htaccess rewrite rules (using mod_rewrite module) is the best way for that.

    I can do it writing this in .htaccess
    `

    Redirect 301 /http://www.example-site-name.com/animals-my-photographs/my-pets-my-photographs/ http://www.example-site-name.com/animals/my-pets/

    `

    but for many links it is not practical, rewrite rules are better. And you know many things, so I thought this is something you could know.

    Just how to remove all instance of "-my-photographs" if more than one in url, hm?
Sign In or Register to comment.