rewrite clean url

I need
http://<hostname>/<album-name>/<photo-name-without-extension&gt;
for my old external links (otherwise)
When I searched on forum photo.jpg has to have jpg extension on url because there could be another photo with png, gif etc.
Is there any way to hack this?
Or
I tried to put a symlink by 'ln -s photo.jpg photo' under albums directory but it does not worked for http://hostname/album/photo (without jpg extension).
Because I have many external links to my photos that I can not edit, I badly need it.
Thanks.
Baris

Comments

  • acrylian Administrator, Developer
    There are more reasons for the suffix besides that there can be a "png" of the same name as for example a "jpg". Internally Zenphoto needs the suffix because `/something/somethingelse/` is also the url of a subalbum `"somethingelse"` of the album `"something"`. So Zenphoto would not know what you actually want or has to check what exists and to use if it exists.

    You could possibly use htaccess to rewrite but since ZP does this internally it would be probably quite inconvenient and complicated.

    The best would be to redirect your old urls to the new ones. But given that the old structure is not really clear that would be a bit complicated. Unless you have only one album level like `/something`. Then you could redirect all `/something/somethingelse` urls to `/something/somethingelse.suffix` to get the actual Zenphoto ones.

    Btw, it is not recommened to use single image page links with just the suffix as this can cause search engines to mistake the single image page for a direct image link. Therefore always `.html` or similar should be appended (the rewrite suffix as we call it).
  • Hi acrylian,
    Thanks for the fast reply.

    I have ~public_html/albums/myalbum/image linked to ~public_html/albums/myalbum/image.jpg

    #cd ~
    #cd public_html/albums/myalbum/
    #ln -s image image.jpg

    but when I want to reach

    http://hostname/myalbum/image

    it does not work although there is symlink file to real image.

    Can I solve this?
  • acrylian Administrator, Developer
    You mistake the single image page we are talking about with the actual image urls. Those are two different urls!

    URL to the single image page `http://www.example.com/albumname/imagename.jpg.html` (`.html` is the rewrite suffix that can be changed via options and must not be an actual suffix, something like `_view` should work as well).
    URL to the actual image `http://www.example.com/albums/albumname/imagename.jpg` ("albums" is the folder on the file system that is not part of the single image page)
  • I need to redirect to
    http://www.example.com/albumname/imagename
    to
    http://www.example.com/albumname/imagename.jpg.html
    whatever method I can.
    Is there any solution for one image or many/all images including symlinks?

    Thanks.
  • acrylian Administrator, Developer
    Problem is still that this conflicts with Zenphoto's own urls for albums since http://www.example.com/albumname/imagename is technically an album url for it. I fear you cannot generally redirect these since that would kill album urls for the first subalbum level.

    If you know you have only this level and don't intend to use further subalbum levels you probably could do that within the root htaccess file before Zenphoto's own redirecting takes place.

    I am not sure about what symlinks you mean. If you mean your old images you have to put all images Zenphoto is supposed to manage into the root "albums" folder anyway. If the server supports symlinks Zenphoto uses them for the resized image cache only. But that is not important here since you don't link to the images directly normally.
  • When I moved from Gallery3 to Zenphoto I had to make several rewrite rules because the image pages in it ended with a "/". For example, here's one I made:

    `RewriteRule ^(misc-pics|my-vehicles|home-theater|cindy-crawford|danica-patrick|humorous|ibm-party|bass-pro-shop|planetary-society-and-seti|getglue-stickers|nature)/(.*)/$ $1/$2.jpg.php? [NC,R=301,L]`

    This is placed above Zenphoto's stuff.
  • Thanks for all reply.
    MarkRH: That's what I want.

    If I remove the last / char ( (.*)/$ -> (.*)$ ) it loops. It works for
    http://hostname/album/photo/
    But I need
    http://hostname/album/photo

    RewriteRule ^(misc-pics|my-vehicles|home-theater|cindy-crawford|danica-patrick|humorous|ibm-party|bass-pro-shop|planetary-society-and-seti|getglue-stickers|nature)/(.*)$ $1/$2.jpg.php? [NC,R=301,L]

    Could you make last touch?

    Thanks.
  • Yeah, I see what you mean. When you take that last "/" out, it also winds up matching the re-written URL as well. You might try putting this above that rewrite to make it skip it. The S=# should be the number of following rules to skip. In this case I am skipping 1 rule.

    `
    RewriteRule ^(.*)\.jpg\.php$ - [S=1]
    RewriteRule ^(album1|album2)/(.*)$ $1/$2.jpg.php? [NC,R=301,L]
    `
    Hope that works.
  • Thanks MarkRH,
    I found below code worked for me (noted here that someone may need it):

    #RewriteCond %{REQUEST_URI} !(\.html|/|php|jpg)$
    #RewriteRule ^(antalya.*|izmir.*|photos.*|istanbul.*|isparta.*|nevsehir.*|image.*|balikesir.*|bursa.*|rize.
    *|canakkale.*|edirne.*|denizli.*|mugla.*|kirklareli.*)/(.*)$ %{REQUEST_URI}.jpg.html [NC,R=301,L]
  • Whatever gets the job done. :)
Sign In or Register to comment.