Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    Hi,

    I have a problem with setting up the error 404 page to be the index.php file in my root folder with microsoft iis 6 (See image attached snap.jpg).

    If I go to my website and type in www.website.com/sfdfsdfsdfs it resolves / redirects to the home page (index.php) which is exactly what I want BUT when I type in www.website.com/folder/adsdasdasd it doesn't redirect to my root folder index.php file but I think takes me to like the root of the directory "folder" as per my example above (see snap2.jpg attached).

    How can I get pages that doen't exist within a directory in my root folder to 404 to my websites root index.php file.

    I hope I make sense here ...

    snap.jpgsnap2.jpg

  2.  

  3. #2
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    1. Custom error pages should be handled on the server level. Depending on your hosting provider, the control panel should have settings for turning them on or off or customizing them.

    2. You should always check to make sure that a customs error ( 404 specifically ), is actually sending back a 404 response back to the requestor... I've seen way too many custom error pages send a 200 response back ( indicating the page is OK ).

    3, you should never "redirect" a 404 page. Search engines don't like redirects... Especially if the customs response has not been verified. ( you can kill you search rankings with that ).

    4. The bottom page shows that the page is displaying without the css.

    Custom error pages are not "served" the same way as standard pages... You cannot pull includes from a virtual location with custom error pages, mainly with IIS, the CSS for the customs error page should be "in page"... For it to render properly. Not sure if apache does the same thing, as I noticed this a while back with IIS and have just always done "in page" CSS on custom error pages... Just to make sure they render properly.

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    IIS is actually functioning properly if your page content is showing up instead of the default IIS6 404 "Page not found" dull page. So you're halfway there...you're just looking in the wrong spot.

    The reason your page appears the way it does is because you've got the wrong path, likely a relative one, to your CSS file. If you have anything like <link rel="stylesheet" type="text/css" src="style.css" />, then IIS will assume style.css is in the same folder as your dead page. So what you need to do to counter this is to use absolute paths i.e. <link relf="stylesheet" type="text/css" src="http://root of your site/style.css" /> and you'll get what you want.

    The downside is that it's a little harder to test locally because your localhost path won't be the same, but I counter this by having a variable called $siteRoot (in PHP) in an include file that looks for the server name and generates the corresponding site root.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  5. #4
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    Hi,

    Thanks Webzarus and Thegame1264 ... you guys are always on the ball!

    @Webzarus ... You certainly know what you're talking about but I'm struggling to understand what you're saying.

    Custom error pages should be handled on the server level. Depending on your hosting provider, the control panel should have settings for turning them on or off or customizing them.
    I have a dedicated server with Godaddy, using Microsoft Windows 2003 iis 6 (I know, ancient hey!!) ... so I do have access to my server and can edit each Custom Error pages on IIS Manager. So yes, I can edit them.

    2. You should always check to make sure that a customs error ( 404 specifically ), is actually sending back a 404 response back to the requestor... I've seen way too many custom error pages send a 200 response back ( indicating the page is OK )
    "I've seen way too many custom error pages send a 200 response back" - isn't that a good thing though?
    How do you check if a custom error page (404 in this case), is sending a 404 response back to the requester?

    3, you should never "redirect" a 404 page. Search engines don't like redirects... Especially if the customs response has not been verified. ( you can kill you search rankings with that ).
    So are you saying that I should create a seperate 404 error page than "redirecting" to the index.php page? Isn't that the same thing though? They both pages at the end of the day?? If so, How would I do this in my situation because iis seems to be a pain!! Set the as URL or FILE?

    The bottom page shows that the page is displaying without the css.
    Yes, correct.

    @Thegame1264

    Thanks for the tip "variable called $siteRoot (in PHP) in an include file". I must look into that. Just to respond to what you're saying, I agree, it looks like it can't find the css file. I honestly didn't think of adjusting the path for the CSS, though before I posted this thread, I was trying to get 404 error pages within a directory to go back to my root index.php file, eg:
    ../index.php
    At the end of the day, I must get this done properly so that nothing effects my rankings! That's the main thing!
    So if I had to sort my CSS pathing out, would this be bad practice if my 404 goes to my home page?
    Or is it a must that I develop a 404 Error page specifically?

    Appreciate you guys helping me!

  6. #5
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Develop a 404 error page specifically. 404 pages are meant for 404 errors...period. You can get creative with your 404 in the sense that you may be able to redirect old content to new content with a 301 and avoid the 404 status code, but you're going to need a 404 error page.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  7. #6
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    Thanks - I don't know why I'm being so thick... I used to know that I had to create a separate 404 error page as I did that with my old site (must be a lack of sleep)!!! I shall do that!

  8. #7
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Maybe you should sleep, then do that.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  9. #8
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    I think there's prioritize at hand here, lol! Thanks for your prompt input... will post here if I come across any issues I need assistance with

  10. #9
    Senior Member
    Join Date
    Mar 2010
    Posts
    104
    Member #
    21316
    Liked
    1 times
    Okay, I've created a 404 error page but what I've done with regards to the CSS style path issue with the main directory within my root ... is I've copied style.css in the root folder and saved it in the directory where I'd most likely get 404's. Is this good / bad practice? Any negatives out of this? All the OTHER pages within the directory will still call style.css within the root folder... so only the 404 page will be using the style.css in the "folder" directory...

    Let me know your thoughts?

  11. #10
    Senior Member Webzarus's Avatar
    Join Date
    May 2011
    Location
    South Carolina Coast
    Posts
    3,322
    Member #
    27709
    Liked
    770 times
    Be careful with the "custom errors"...

    There are quite a few sites that you can check your page response status with.

    Here's the deal... If you look at a detailed log file... Every time a file is requested... The server responds with an appropriate code...

    200 - good response - here's the page
    304 - good response - retrieve the requested file from your memory
    404 - bad response - page or file doesn't exist - display custom or default error page
    500 - bad response - permission errors etc...

    You get the hint.

    Anyway, many of the so called "custom" error page generators... Will not send a genuine 404 back to the requestor before displaying the error page. On the contrary, many send a 200 response... Telling the requestor that everything is good...

    What happens when a search engine ... You do know they don't actually look at your pages right ? They look for "responses"... If 200... Add it to the list to be indexed... 301 ( redirect ), add it to the list to be indexed, and drop old address from indexing... On and on...

    Well, if your error pages are sending back a 200 response ... After 3 or 4 errors... The search engines realize or think you have a whole bunch of identical pages...

    There are numerous sites that offer "page response checking"... Call a page that doesn't exist on your site... If the response is anything but 404... You will need to find a "page level" piece of code to force the "404 response" ....

    And search engines don't like redirects... Unless its a 301 or 302 redirect ( the real only way to inform search engines that your site structure or information has moved )...any other type of redirect ...

    Now that being said.... Once a search engine receives a 404 for something that doesn't exist... You could theoretically do a page level meta-refresh ... And send the user somewhere... But generally I don't push the matter ...

    If you have a lot of 404 errors on your site, there are other issues at hand that should be fixed first.

    Sure, there are "old links", etc... But those should actually be handled by 301's to inform search engines that the content has moved ...


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

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

Search tags for this page

404 error page not pulling php include
,

redirect 404 php in iis6

Click on a term to search for related topics.
All times are GMT -6. The time now is 05:45 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com