NginX redirect fails

Discussion in 'Installation/Configuration' started by itsnedkeren, Mar 22, 2012.

  1. itsnedkeren

    itsnedkeren New Member

    Hi all,

    Trying to redirect http://domain.tld to http://domain.tld/gallery

    ISPConfig setup:
    Redirect type = permanent
    Redirect path = http://domain.tld/gallery/
    Which generates these lines in the NginX vhost file:

     if ($http_host ~* "^domain.tld$") {
                rewrite ^/(.+)$ http://domain.tld/gallery/$1 permanent;
            if ($http_host ~* "^www.domain.tld$") {
                rewrite ^/(.+)$ http://domain.tld/gallery/$1 permanent;
    If an index.html file is present in http://domain.tld, the resulting URL is:

    If NO index.html file is present, I get this error:

    403 forbidden
    System info:
    Debian 6.0
    NginX 1.0.14 (dotdeb)

    Please assist, I've tried everything.

    Best regards
    Last edited: Mar 22, 2012
  2. falko

    falko Super Moderator ISPConfig Developer

    I've added this to our bugtracker, so we will check that.
  3. jbd123

    jbd123 New Member

    I came up against this issue as well, none of the redirect options worked in Nginx and for permanent redirects we got the OP issue with the recursive paths.

    I added a manual redirect to suit our requirements, which was to redirect a domain to a specific path using a permanent redirect HTTP code.

    if ($http_host ~* "^$") {
    rewrite ^.+$ permanent;

    Obviously there are improvements around that using try_files but it works for now.

    If I'm reading it correctly, the rewrite ISPC adds would only work if the URL has a trailing slash:

    rewrite ^/(.+)$ http://domain.tld/gallery/$1 permanent;

    What is the bug # , searched but couldn't find it?
    Last edited: Aug 20, 2012
  4. falko

    falko Super Moderator ISPConfig Developer

  5. jbd123

    jbd123 New Member

    Great, thanks, any news on 3.0.5 release date. I have people asking why redirects aren't working so I'd like to give them an ETA.


  6. falko

    falko Super Moderator ISPConfig Developer

    There's no release date yet. I'd expect it in October, but there's excessive testing to be done...

Share This Page