How to change .jpg to .html

How to change .jpg to .html
example:

I would like to change:
http://host.com/cars/bmw.jpg

to
http://host.com/cars/bmw.html

I guess it is in htaccess? but I can't find a write place to edit it?
Could someone help me with this?

Thanks
Plodz1

Comments

  • replace
    RewriteRule ^([^/\.]+)/([^/\\]+)$ index.php?album=$1&image=$2 [QSA,L]
    with
    RewriteRule ^([^/\.]+)/([^/\\]+)\.html$ index.php?album=$1&image=$2 [QSA,L]
    it change bmw.jpg to bmw.jpg.html
    but you can't change bmw.jpg to bmw.html, since php will not know it is a bmw.jpg or bmw.gif or ....
    Also, you have change all the functions which generate URLs in the template-functions.php
  • I try to replace this one, but don't work. What can I have faild?
  • im assuming its

    $g_album = urlencode($g_album); $g_image = urlencode($g_image);
    header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . WEBPATH . "/" .
    (zp_conf('mod_rewrite') ? "$g_album/$g_image" : "index.php?album=$g_album&image=$g_image"));
    exit;
    } else {
    $stored = array($_POST['name'], $_POST['email'], $website, $_POST['comment'], false);
    if (isset($_POST['remember'])) $stored[3] = true;
    $error = true;
    }

    from template-functions.php

    that needs to be modified but what in it needs to be modified
  • trisweb Administrator
    The problem is that the .jpg is actually part of the filename... it's there for a darn good reason. It would be much easier to add a /view.html or something *after* the filename.jpg, which is easily done in .htaccess alone.

    I would not recommend changing the filename handling. It will run you into MANY problems, trust me.
  • Hello,

    How do you add /view.php after the filename.jpg in the .htaccess file.

    Thanks!
  • bump. Sorry for being impatient.
  • trisweb Administrator
    Ah, good question, sorry I missed it.

    As has been said above, it also requires changes to the template functions to change the links. Perhaps this is something that can be abstracted (like 'Permalink Structure' in Wordpress).

    In the .htaccess file alone, here's how: The last rule:

    `RewriteRule ^([^/]+)/([^/\]+)$ index.php?album=$1&image=$2 [L,QSA]`

    Becomes:

    `RewriteRule ^([^/]+)/([^/\]+)/view.php$ index.php?album=$1&image=$2 [L,QSA]`

    Then go through template-functions.php, find the function `getImageLinkURL()`, and on the line that reads:

    ` return WEBPATH . "/" . urlencode($_zp_current_album->name) . "/" . urlencode($_zp_current_image->name);`

    Change it to:

    ` return WEBPATH . "/" . urlencode($_zp_current_album->name) . "/" . urlencode($_zp_current_image->name) . "/view.php";`

    Then all your image viewing pages will have /view.php after them. I might just make this an option, it'd be very easy. Let me know how it works for you.
  • Hello!

    Thank you very much, it works as expected except for one big thing.

    The comment form with the action of "#" takes the user to the path of the image.php page (the large image detail page) *before* the "view.php" was added at the end, like this:

    http://www.domain.com/gallery/album-name/imagename.jpg - which returns a 404 error

    instead of

    http://www.domain.com/gallery/album-name/imagename.jpg/view.php

    I did have to add the /view.php after the links in the themes.

    <?=getPrevImageURL();?>/view.php

    But everything I try with respect to the form, only returns a 404 error. For now, I'm just playing around with zenphoto, so it's no biggie.

    Please let me know what I can do to fix this.

    Thanks!
  • Okay. I figured out a non surgical way of doing it. Since the main objective for the view.php at the end is for search engines, I did the following in the .htacess file:

    RewriteRule ^([^/]+)/([^/\]+)/view.php$ index.php?album=$1&image=$2 [L,QSA]

    RewriteRule ^([^/]+)/([^/\\]+)$ index.php?album=$1&image=$2 [L,QSA]

    So when the comment is posted they go to the page with the file ending in .jpg, no big deal.

    Anyway it works fine now.
  • How to change .jpg to .html ?.... I tried the hack with view.php/html ... It works fine ....but I need to remove the .jpg part from the link .
    I tried hacking some classes and functions ...and change the $filename to $name in the links .
    It works .... I got links to look like this : /album/image file name (but no .jpg/.gif,etc).

    I just need to add the .html part to the last part of the link.
    Any ideeas ?
  • Tristan posted earlier:

    I would not recommend changing the filename handling. It will run you into MANY problems, trust me.

    ******

    But how did you do it? I'm curious.

    Why not do

    album/imagefilename(without.jpg)/view.html
  • trisweb Administrator
    If you assume everything is .jpg, then it would work fine... you just have to change the rule...

    `RewriteRule ^([^/]+)/([^/]+)$ index.php?album=$1&image=$2 [L,QSA]`

    Becomes:

    `RewriteRule ^([^/]+)/([^/]+)$ index.php?album=$1&image=$2.jpg [L,QSA]`

    That will make it work, theoretically, but you still have to change all the generated URL's in zenphoto (there are a lot of them) to output "`imagename`" instead of "`imagename.jpg`", which is tedious, but possible...

    Again, you lose all support for anything but .jpg if you do this.
Sign In or Register to comment.