Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,098
    Thanks
    27
    Thanked 0 Times in 0 Posts

    Backing up One Page is causing 404-Error

    I am getting a really strange error that - for the life of me - I cannot track down...

    Here is what is happening...

    The user starts from his/her Inbox located here...

    http://local.debbie/account/messages/incoming


    The user click on a given Private Message in his/her Inbox and is taken to the PM to a URL similar to this...

    http://local.debbie/account/view-pm/incoming/4


    Next, the user decides he/she wants to back up to the Inbox, and so (on my Mac) chooses Command + Back-Arrow.


    While the browser goes back one page to the Inbox, and everything loads just fine, in the background, the browser or my code is apparently throwing a 404-Error.

    I know this because in my .htaccess file I have this code...

    Code:
    #Handle Page Not Found.
    ErrorDocument 404 "/utilities/page-not-found.php"
    ...and that script is running which sends me an e-mail saying there was an issue.


    Like a lot of things late in the game of developing my website, it is hard to troubleshoot if you don't have my entire code base, and yet I am hoping someone out there has seen something similar and may have som ideas of how to fix this?!

    It would be a real bummer if I - as the Admin - get an e-mail every time someone backs up from a PM to their Inbox!!!!!

    Any ideas??

    Sincerely,


    Debbie

  • #2
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,098
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Actually, it looks like the 404-Error may be occurring just when the PM page loads, versus backing up to it.


    If I open up a new browser, and paste this in the Address Bar...

    http://local.debbie/account/view-pm/incoming/4

    ...and hit <enter>, then I get an e-mailing saying there was a 404...


    (I don't understand how a Page can load AND throw a 404-Error all at the same time?!)


    Debbie

  • #3
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,098
    Thanks
    27
    Thanked 0 Times in 0 Posts
    I think I have the issue isolated, but still have no clue about what is wrong...

    In my "view-pm.php" script which displays a Private Message, I have this snippet of code which builds the From: part of the message...

    PHP Code:
        if ($msgView == 'incoming'){
            
    $fromData "<a href='/account/profile/$fromUsername/about-me'>"
            
    $fromUsername
            
    "<img id='onlineStatus' src='/images/"
            
    $fromMemberStatus[0]
            . 
    "' width='10' alt='"
            
    $fromMemberStatus[1]
            . 
    "' /><br />"
            
    "<img src='/uploads/"
            
    $fromPhoto
            
    "' width='80' />"
            
    "</a>";

    echo 
    '$fromData = ' $fromData "<br />";
    exit(); 

    If I isolate this code, run the script, and view the output I get...

    Code:
    $fromData = <a href='/account/profile/username1/about-me'>username1<img id='onlineStatus' src='/images/Light_Gray_10.png' width='10' alt='Member Offline' /><br /><img src='/uploads/NoImage2_100x77.png' width='80' /></a><br />

    Apparently this PHP and/or HTML is causing a 404-Error when my Private Message displays?!


    What in the world is going on????


    Debbie

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    That will ultimately come down to your rewrite rules. If I had to guess, one of them has a trailing / on it, and the rewrite engine either only handles it with the trailing front slash or doesn't handle it. One or the other would trigger an error since it is now looking for a directory which presumably doesn't exist.

  • #5
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,098
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    That will ultimately come down to your rewrite rules. If I had to guess, one of them has a trailing / on it, and the rewrite engine either only handles it with the trailing front slash or doesn't handle it. One or the other would trigger an error since it is now looking for a directory which presumably doesn't exist.
    Fou-Lu, did you see my latest post (i.e. Reply #3)??


    Debbie

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    And what is your question to go with that? It matches the output $from variable you have created.

  • #7
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,098
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    And what is your question to go with that? It matches the output $from variable you have created.
    I am wondering all the mod_rewrites I used - only a dozen really - are worth the trouble they can cause?!


    Okay, I think I am making some progress thanks to your lead, so here is where I am stuck now...

    In my Web Root I have a directory called "uploads" which holds Member's profile photos plus a png to handle if a photo is "pending approval" and one if the Member has no photo.

    For whatever reason, I had the wrong filename in my code, and so I corrected below...
    PHP Code:
        // Check for No Image.
        
    if (is_null($fromPhoto)){
            
    $fromPhoto "NoImageAvailable_100x77.png";
        }

        if (
    is_null($toPhoto)){
            
    $toPhoto "NoImageAvailable_100x77.png";
        } 

    So, when I re-run my code with an exit() to isolate things, in View Source I see...

    Code:
    src='/uploads/NoImageAvailable_100x77.png'

    If I type this in the URL I get a 404-Error...

    local.debbie/uploads/NoImageAvailable_100x77.png


    So to me that means that the HTML that is trying to display my "No Image Available" thumbnail is crashing things...


    The best thing I can think, is that is very liberal mod_rewrite could be causing an issue...

    Code:
    #-------------------------------------------------------------------------------
    #PRETTY:		finance/
    #UGLY:			articles/index.php?section=finance
    
    #Rewrite only if the request is not pointing to a real file (e.g. add-comment.php, index.php).
    RewriteCond %{REQUEST_FILENAME} !-f
    
    #Match any kind of Section.  PHP will decide if it's valid or not.
    RewriteRule (.+)/$ articles/index.php?section=$1 [L]

    Does that make sense??


    Debbie

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Yeah, rewrites can cause havoc.

    Are all of these rewrites like this? If so:
    PHP Code:
    RewriteRule (.+)/$ articles/index.php?section=$[L]
                    ^ 
    You require the / at the end of it. Without it it will consider it a directory.

  • #9
    Senior Coder doubledee's Avatar
    Join Date
    Mar 2011
    Location
    Arizona
    Posts
    1,098
    Thanks
    27
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Yeah, rewrites can cause havoc.
    This is madness!!!

    I think I figured out the culprit...

    For some reason in my code I originally had...
    Code:
    $fromPhoto = "NoImage2_100x77.png";

    Then I thought I noticed it should be...
    Code:
    $fromPhoto = "NoImageAvailable_100x76.png";

    And after more errors I looked again and noticed that I needed...
    Code:
    $fromPhoto = "NoImageAvailable_100x77.png";

    WTF?!


    Quote Originally Posted by Fou-Lu View Post
    Are all of these rewrites like this? If so:
    PHP Code:
    RewriteRule (.+)/$ articles/index.php?section=$[L]
                    ^ 
    You require the / at the end of it. Without it it will consider it a directory.
    No, I just have it like that in one place, which is probably a whole long discussion in itself...

    For each "Article Section" in my website, which is a "navigation tab" and a landing page containing a summary of each Article, right or wrong, I adopted this format in the URL...

    http://local.debbie/finance/

    http://local.debbie/legal/

    http://local.debbie/management/


    To me, it seemed like a good idea at the time, because ending a URL with a slash denotes that you are looking into a directory, and I guess my "Finance Landing page" is a "directory" of sorts?!

    It's much too late to change that for v2.0, but if you think my convention is a bad idea or misleading, I guess I could re-work it for v3.0

    Suggestions?

    Thanks,


    Debbie

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Your rewrite can just take /? on it to make it optional.
    The source image paths are irrelevant. Unless its somehow matching your rewrite rules which is very easy to do. Your current rules only check to see if a file matches, otherwise it goes ahead and rewrites. Assuming the style is overall the same, not matching a filepath for an image would attempt to rewrite it. I wouldn't think that would cause a 404 on a page though; all that should do is show a broken image link since the image itself is a 404.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •