apache technical question anyone!?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MrJackMeHoff
    Confirmed User
    • Mar 2004
    • 4569

    #1

    apache technical question anyone!?

    Sorry a bit off topic but im in a pinch to find this.

    How do you pass the broken link in a 404 to a script? Here is an example:

    ErrorDocument 404 404/404.pl?brokenlink=$LinkITried
  • masterE
    Confirmed User
    • Aug 2004
    • 366

    #2
    Use REQUEST_URI

    PHP Code:
    brokenLink=<!--#echo var="REQUEST_URI" --> 
    

    Promote Lady Sonia
    and earn 60% on sign-up and 60% on rebills!
    ^^ Weekly CCBill Payouts - Hosted Galleries - Promo Content - Free Hosting ^^
    ^^ No Cross Sells - No Traffic Leaks - 100% Exclusive Content! ^^

    Comment

    • EscortDate_Enoj
      Registered User
      • Mar 2002
      • 87

      #3
      Originally posted by MrJackMeHoff
      Sorry a bit off topic but im in a pinch to find this.

      How do you pass the broken link in a 404 to a script? Here is an example:

      ErrorDocument 404 404/404.pl?brokenlink=$LinkITried
      I use
      Code:
      ErrorDocument 404 /index.php?module=error&code=404
      and then when index.php is requested by Apache the environment will be as if the file which was not found existed. Take a look at for example the $_SERVER (PHP example) array when you request a 404 file.

      I've seen it behave otherwise on other servers though, where the user plainly gets redirected to the 404 page instead. I assume it's some Apache directive for how to show error documents.

      1:287 all November with UnrealBank

      Comment

      • MrJackMeHoff
        Confirmed User
        • Mar 2004
        • 4569

        #4
        Originally posted by masterE
        Use REQUEST_URI

        PHP Code:
        brokenLink=<!--#echo var="REQUEST_URI" --> 
        
        This doesnt do anything 'cept pass the acho command.. Im needing this for .htaccess.. I tried using php as the 404 and invoking request_uri but all i get is the current script name or the html it came from. Not the link that was 404 to begin with.

        Comment

        • MrJackMeHoff
          Confirmed User
          • Mar 2004
          • 4569

          #5
          Originally posted by EscortDate_Enoj
          I use
          Code:
          ErrorDocument 404 /index.php?module=error&code=404
          and then when index.php is requested by Apache the environment will be as if the file which was not found existed. Take a look at for example the $_SERVER (PHP example) array when you request a 404 file.

          I've seen it behave otherwise on other servers though, where the user plainly gets redirected to the 404 page instead. I assume it's some Apache directive for how to show error documents.
          php is only showing the php as the link I requested on my server. Not the link I really wanted.

          Comment

          • masterE
            Confirmed User
            • Aug 2004
            • 366

            #6
            Setup a normal 404 page, then request the script in your 404 page with an image tag using the REQUEST_URI

            Promote Lady Sonia
            and earn 60% on sign-up and 60% on rebills!
            ^^ Weekly CCBill Payouts - Hosted Galleries - Promo Content - Free Hosting ^^
            ^^ No Cross Sells - No Traffic Leaks - 100% Exclusive Content! ^^

            Comment

            • MrJackMeHoff
              Confirmed User
              • Mar 2004
              • 4569

              #7
              Originally posted by masterE
              Setup a normal 404 page, then request the script in your 404 page with an image tag using the REQUEST_URI
              Say what? Oh I just found out I cant use php anyway it has to be perl.


              there isnt just a fucking variable in apache to pass this? Geez why does this have to be so difficult? ;)

              Comment

              • andi_germany
                Confirmed User
                • Oct 2002
                • 768

                #8
                You have to edit your httpd.conf and and uncomment or add the ErrorDocument 404 directive. This can be set global or in your virtual section.

                ErrorDocument 404 /404.html works as well as a external redirect with a complete URL. (note that in this example 404.html would have to be present in your document root dir.)

                There should be some example lines in your httpd.conf

                If you don't have access to your conf files you can also use .htaccess to forward the404 errors
                Last edited by andi_germany; 09-27-2004, 09:42 PM.
                SIG TOO BIG! Maximum 120x60 button and no more than 3 text lines of DEFAULT SIZE and COLOR. Unless your sig is for a GFY top banner sponsor, then you may use a 624x80 instead of a 120x60.

                Comment

                • lb_vee
                  Confirmed User
                  • May 2004
                  • 886

                  #9
                  Originally posted by MrJackMeHoff
                  Sorry a bit off topic but im in a pinch to find this.

                  How do you pass the broken link in a 404 to a script? Here is an example:

                  ErrorDocument 404 404/404.pl?brokenlink=$LinkITried
                  try adding a slash in front of the first directory.

                  Comment

                  • lb_vee
                    Confirmed User
                    • May 2004
                    • 886

                    #10
                    I just realized you're trying to pass a variable to it.

                    The referer will be picked up by the script automatically. If you're using perl as cgi, look into the CGI.pm docs to see how its passed.

                    If its mod-perl, checkout the Apache::Registry docs

                    I think the refering url is also an @ENV variable.

                    $ENV{'HTTP_REFERER'};

                    Replace the haha shit up top with a shift+[
                    Last edited by lb_vee; 09-27-2004, 09:47 PM.

                    Comment

                    • Theodor S. Geisel
                      Confirmed User
                      • Jul 2003
                      • 349

                      #11
                      Originally posted by MrJackMeHoff
                      Sorry a bit off topic but im in a pinch to find this.

                      How do you pass the broken link in a 404 to a script? Here is an example:

                      ErrorDocument 404 404/404.pl?brokenlink=$LinkITried
                      2 things you have to keep in mind.

                      1. Make sure everything is relative. /404/404.pl is a good start.
                      2. IE will *NOT* show your custom 404 page if your 404 page is less than 10k. You can just fill the damn page with dots. That'll work.
                      Theodor S. Geisel
                      [ ICQ: 2 0 6 6 1 0 7 ]
                      [ theodor.geisel -at- gmail -d0t- com ]
                      [ PROGRAMMER :: PHP :: MYSQL :: HTML/CSS ]

                      Comment

                      • MrJackMeHoff
                        Confirmed User
                        • Mar 2004
                        • 4569

                        #12
                        Originally posted by a1escorts
                        I just realized you're trying to pass a variable to it.

                        The referer will be picked up by the script automatically. If you're using perl as cgi, look into the CGI.pm docs to see how its passed.

                        If its mod-perl, checkout the Apache::Registry docs

                        I think the refering url is also an @ENV variable.

                        $ENV{'HTTP_REFERER'};

                        Replace the haha shit up top with a shift+[
                        I dont want the referer I want the link you click on that is dead so i can work with it in perl. I have the referer already. ;)

                        Comment

                        • MrJackMeHoff
                          Confirmed User
                          • Mar 2004
                          • 4569

                          #13
                          Originally posted by Theodor S. Geisel
                          2 things you have to keep in mind.

                          1. Make sure everything is relative. /404/404.pl is a good start.
                          2. IE will *NOT* show your custom 404 page if your 404 page is less than 10k. You can just fill the damn page with dots. That'll work.
                          The script runs fine just no way to display the link that was dead in the first place.

                          Comment

                          • lb_vee
                            Confirmed User
                            • May 2004
                            • 886

                            #14
                            Originally posted by MrJackMeHoff
                            The script runs fine just no way to display the link that was dead in the first place.
                            in the environment variables, look at REDIRECT_ERROR_NOTES or REQUEST_URI, thats the page that called the 404 (the page that doesnt exist)

                            Comment

                            • MrJackMeHoff
                              Confirmed User
                              • Mar 2004
                              • 4569

                              #15
                              Originally posted by a1escorts
                              in the environment variables, look at REDIRECT_ERROR_NOTES or REQUEST_URI, thats the page that called the 404 (the page that doesnt exist)
                              No matter what I do I just get the page the person was last on or the page they are currently on I cant seem to get the page they wanted to be on that was 404.

                              Comment

                              • lb_vee
                                Confirmed User
                                • May 2004
                                • 886

                                #16
                                Originally posted by MrJackMeHoff
                                No matter what I do I just get the page the person was last on or the page they are currently on I cant seem to get the page they wanted to be on that was 404.
                                does the 404 redirection work??

                                I tested this on one of my servers and it works fine. Double check your perl / apache settings.

                                Comment

                                Working...