Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nostromo

macrumors 65816
Original poster
Dec 26, 2009
1,358
2
Deep Space
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.
 
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.
 
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.

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.
 
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.
 
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.
 
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.

I am getting errors for each of the links above, actually...
 
I am getting errors for each of the links above, actually...

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.
 
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.
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.