zenphoto-rewrite.txt to redirect pages.

ctdlg Member
edited June 2020 in General support

My question is about the zenphoto-rewrite.txt file : I cannot use it !

I want to redirect a domain to another one.
I created a new domain name; the new one and the old one are on the same distant directory.
Both addresses do work, but the old address should be redirected to the new one.
.htaccess does not help, because of zenphoto-rewrite.txt

The following code at the beginning of zenphoto-rewrite.txt does not work

RewriteCond %{HTTP_HOST} ^dominotes.fr$
RewriteRule ^/?$ https://dominotes.fr [R=301,L]

I get
instead of
I cannot remove the beginning of the address with above code : txt rewriterule seems to be different from .htaccess rewriterule

I have also tried
RewriteRule /?$ https://dominotes.fr [R=301,L]
RewriteRule ^?$ https://dominotes.fr [R=301,L]
RewriteRule ^/$ https://dominotes.fr [R=301,L]
No success !

Adding the correct code at the beginning of .htaccess does nothing as if it's overridden by zenphoto-rewrite.txt
RewriteEngine On
RewriteCond %{HTTP_HOST} ^oldsite\.fr$
RewriteRule ^/?$ "https:\/\/dominotes.fr\/" [R=301,L]

I have not found any htaccess to txt file converter !


  • First, if your code does not work in the root .htaccess file then there is something wrong with it or your site's rewrite handling.

    .htaccess rules are processed before any zenphoto code gets executed.

    Second, the intent of the internal rewrite handling is to service zenphoto SEO and aliasing. So, for instance, there is no code to process the RewriteCond directive since there (at present) is no need for the construct.

    The reason for handling the rules internally is twofold. First to make the .htaccess file (or equivalent for non-apache servers) as simple and constant as possible. Second it to allow the rules to be dynamic so that plugins, etc. can mold them to their needs.

    What you seem to want to do--redirect from an old site domain to a new site domain--is properly the job of the server rewrite handler.

  • ctdlg Member

    Thank you sbillard...
    And I understand better the zenphoto-rewrite.txt file

    The code was ok , BUT
    If I modify .htaccess with filezilla, it does not work.
    I must use the online editor provided in my Cpanel (o2switch),
    using same code -> it does work.

    This message might help some other zenphoto user !

  • acrylian Administrator, Developer

    I want to redirect a domain to another one.

    If both domains are on your same server, you should also look at your webhost's panel for your webspace as it probably features some setting for this already. Then you don't need to use htaccess at all.

  • ctdlg Member

    @acrylian :
    I used my webhost's panel to generate the code automatically, problem was that this code was added at the end of the zenphoto .htaccess file.
    Moving the code to the top with filezilla did not work, no redirection, this is why I thought I had to use zenphoto-rewrite.txt file.

    I moved the code inside zenphoto's .htaccess file with my webhost's panel editor.
    Same code, but it does work ... using the webhost's panel editor for the 1st time showed an original zenphoto .htaccess file with all zenphoto code plus the redirecting code at the end - Filezilla showed same redirecting code at the beginning.

    This means my webpanel manages the redirecting code !

    Strange, because if I write with a french pen or a german pen, I will read the same words, not 2 different texts !

    Thank you for your help.

    Note : I moved from php 7.2 to php 7.4, with zenphoto 1.5.7, and everything is faster. (7.4 is faster than 7.2)
    Again, version 1.5.7 is great.
    Again, congrats !

  • acrylian Administrator, Developer
    edited June 2020

    Yes, such redirection code belongs to the beginning before everythging else follows.

    However I was not referring to any htaccess editor via your host but some domain management tool to provide some means to define where a domain on your server is linked to. Be it a folder on the webspace or another domain or subdomain.

    Not all hosts are the same and some might not have that although all I know do. This is usually not done via htaccess directly to see via FTP but "behind the scenes" in some internal server configuration (perhaps it is htaccess on some root level as well, I don't really know).

    And yes, php 7 in general is much faster than 5 ever was. Thanks.

Sign In or Register to comment.