Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Allow redirecting common HTTP codes

    Surfer
    4
    9
    282
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • murgero
      murgero App Dev last edited by

      I'd like to request that we allow certain HTTP codes to be redirected to certain files if they exist:

      Example:

      If 404 (file not found) and my little website has a 404.html, it should use that instead of the surfer default.

      --
      https://urgero.org
      ~ Professional Nerd. Freelance Programmer. ~
      Matrix: @murgero:urgero.org

      robi 1 Reply Last reply Reply Quote 3
      • robi
        robi @murgero last edited by

        @murgero Can this be accomplished with a bit of JS in the page?

        Otherwise it may make sense to use something like caddy2 which has a host of other features and configuration options.

        Life of Advanced Technology

        1 Reply Last reply Reply Quote 0
        • nebulon
          nebulon Staff last edited by

          Good idea. Do you think some convention is good enough? Like as you said if the document root contains a file of the name schema <statucode>.htm(l), surfer should deliver that?

          This would not require any further UI and settings.

          fbartels murgero 2 Replies Last reply Reply Quote 1
          • fbartels
            fbartels App Dev @nebulon last edited by

            @nebulon yes that would be a good approach, as it would immediately be compatible with some static site builders such as Hugo.

            1 Reply Last reply Reply Quote 1
            • murgero
              murgero App Dev @nebulon last edited by murgero

              @nebulon Yes I like that approach. Or maybe a settings page that has the ability for admins to specify a file for each status code. They can give the status code they want to redirect for and the file to redirect to.
              Certain status codes should be ignored however: Specifically:

              • 100
              • 101
              • 102
              • 103
              • 200
              • 201
              • 202
              • 203
              • 205
              • 206
              • 207
              • 208
              • 226

              @robi

              Can this be accomplished with a bit of JS in the page?

              No as what I am asking for happens before a page is loaded, not after.

              --
              https://urgero.org
              ~ Professional Nerd. Freelance Programmer. ~
              Matrix: @murgero:urgero.org

              1 Reply Last reply Reply Quote 1
              • nebulon
                nebulon Staff last edited by

                For a start this really only applies to 404.html as far as I can tell.

                murgero 1 Reply Last reply Reply Quote 1
                • murgero
                  murgero App Dev @nebulon last edited by

                  @nebulon I would do Status codes 4XX to cover most client-side status codes to start

                  --
                  https://urgero.org
                  ~ Professional Nerd. Freelance Programmer. ~
                  Matrix: @murgero:urgero.org

                  1 Reply Last reply Reply Quote 1
                  • nebulon
                    nebulon Staff last edited by

                    This is now fixed with version 5.15.0

                    I only added support for 404 pages for now, since this is the only 4* error code the app would publicly serve up anyways.

                    murgero 1 Reply Last reply Reply Quote 4
                    • murgero
                      murgero App Dev @nebulon last edited by

                      @nebulon I can confirm the update works very well - Thank you!

                      --
                      https://urgero.org
                      ~ Professional Nerd. Freelance Programmer. ~
                      Matrix: @murgero:urgero.org

                      1 Reply Last reply Reply Quote 1
                      • First post
                        Last post
                      Powered by NodeBB