mywebsite.com/portraits gives 404 error even though page exists

Discussion in 'Web Design and Development' started by Nostromo, Jul 20, 2010.

  1. Nostromo macrumors 65816

    Nostromo

    Joined:
    Dec 26, 2009
    Location:
    Deep Space
    #1
    I printed the address "mywebsite.com/portraits" on my most recent postcard.

    Now when I tried to access this page, I get a 404 error - page not found.

    But it exists.

    If I put in mywebsite.com/portraits.html, the page loads.

    What do I have to do so people can access this page without typing the .hmtl at the end (nobody does this).

    Thanks for your tips.
     
  2. definitive macrumors 68000

    definitive

    Joined:
    Aug 4, 2008
    #2
    make a folder called myportraits, and rename the .html into index.html
     
  3. Nostromo thread starter macrumors 65816

    Nostromo

    Joined:
    Dec 26, 2009
    Location:
    Deep Space
    #3
    Thank you!

    This was so helpful!

    I put the CSS file into the same folder, and it worked nicely!
     
  4. manueld macrumors 6502

    Joined:
    Jun 8, 2009
    #4
    or instead of creating folders, you can do an htaccess rewrite that would rewrite any requests that doesn't have an extension and append the html to it.
     
  5. DJBenE macrumors member

    Joined:
    Jul 9, 2010
    Location:
    Rowland Heights, California
    #5
    Good idea and all but bad idea for SEO. Don't want to make the search engines mad about duplicate content or even more 404 pages!

    htaccess:
    Code:
    RewriteEngine on
    RewriteRule ^portraits/ /portraits.html
    ...to handle just that one instance.
     
  6. Nostromo thread starter macrumors 65816

    Nostromo

    Joined:
    Dec 26, 2009
    Location:
    Deep Space
    #6
    I think the folder idea works very well.

    I store the CSS file in the same folder, and only have to add a ../ to connect to content like image files that are in another folder.
     
  7. Nostromo thread starter macrumors 65816

    Nostromo

    Joined:
    Dec 26, 2009
    Location:
    Deep Space
    #7
    The above solution has a big problem.


    I wanted to enable people to go to a page like www.mywebsite.com/portraits without writing the .html

    So we put the page into the folder "portraits" and called it "index.html".

    Now, when you type www.mywebsite.com/portraits you come out at mywebsite.com/portraits it displays the page correctly, but no link from this page works.

    When I access the same page from another page on my website, the name is www.mywebsite.com/portraits/index.html. Now all the links work.


    So the above method of putting a page into its own folder creates two names for the same page and destroys the page structure of the site. It's impossible to navigate to any other page from this landing page www.mywebsite.com/portraits.


    I don't know why this method is creating two addresses for the same page.
     
  8. designguy79 macrumors 6502

    Joined:
    Sep 24, 2009
    Location:
    Michigan
    #8
    I am getting errors for each of the links above, actually...
     
  9. Nostromo thread starter macrumors 65816

    Nostromo

    Joined:
    Dec 26, 2009
    Location:
    Deep Space
    #9
    Those aren't real links.

    I just put www.mywebsite.com instead of my real website's name to keep things private.


    The key problem is, that somehow the link out of the portraits folder doesn't work.

    I put in the link <a href="../portraits_portfolio.html"></a>, but when the browser reports the error:

    can't find the file "portraits/portraits_portfolio.html". He's looking for the portfolio inside the folder "portraits". But the ../ should make him look on the next level up. Somehow the browser doesn't get it. This is the key issue here.
     
  10. designguy79 macrumors 6502

    Joined:
    Sep 24, 2009
    Location:
    Michigan
    #10
    Drrr, I should have known that! :eek:

    Are you using the base tag?

    Also, try an absolute link, like this:

    <a href="/portraits_portfolio.html">Portraits</a>

    (site note: that will break if your site is ever stuffed in its own folder)

    It is hard to debug your HTML without seeing the whole thing...

    HTH.
     
  11. Nostromo thread starter macrumors 65816

    Nostromo

    Joined:
    Dec 26, 2009
    Location:
    Deep Space
    #11
    edit:

    Note to myself - after rewriting a website, clear the cache.

    Didn't know that modern browser still can't update changed content of website and continue using outdated data stored in their cache.
     

Share This Page