The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> removing .html extension in folders
matthewhunt
post Aug 16 2017, 10:30 PM
Post #1





Group: Members
Posts: 9
Joined: 15-February 07
Member No.: 1,910



I have a site with pages organised into different folders. For example:

http://www.matthewhunt.com/cinema/index.html

I can access this page by typing http://www.matthewhunt.com/cinema/ but http://www.matthewhunt.com/cinema (without the final /) returns a 404 error.

How can I configure to access via http://www.matthewhunt.com/cinema (without the final /)?

Thank you.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 17 2017, 05:56 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,628
Joined: 10-August 06
Member No.: 7



Normally a URL without a trailing slash indicates a file, not a directory. This can be changed on the server in various ways, details may differ between web hosts.

Personally I'd keep the slashes for directories, it's both simpler and easier to understand.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
matthewhunt
post Aug 17 2017, 06:23 AM
Post #3





Group: Members
Posts: 9
Joined: 15-February 07
Member No.: 1,910



QUOTE(Christian J @ Aug 17 2017, 05:56 AM) *

Normally a URL without a trailing slash indicates a file, not a directory. This can be changed on the server in various ways, details may differ between web hosts.


Thanks, Christian. I should have explained that the destination is the index.html file in the directory, not the directory itself. Is it possible to set the URL http://www.matthewhunt.com/cinema (for example) to open the index.html file in the /cinema/ directory?

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 17 2017, 07:23 AM
Post #4


.
********

Group: WDG Moderators
Posts: 9,628
Joined: 10-August 06
Member No.: 7



QUOTE(matthewhunt @ Aug 17 2017, 01:23 PM) *

Is it possible to set the URL http://www.matthewhunt.com/cinema (for example) to open the index.html file in the /cinema/ directory?

The IIS server seems to do that by default, according to https://support.microsoft.com/en-us/help/29...ailing-slash-is (note that it seems to redirect the URL, not just serve the content of matthewhunt.com/cinema/index.html while retaining the URL matthewhunt.com/cinema).

The Apache server may require .htaccess directives: https://serverfault.com/questions/250161/ho...efault-director

Sometimes web hosts have already implemented various features that may complicate things. Blogging scripts may also use their own features.

But see also http://webtips.dan.info/subdir.html#FinalSlash on why it may be a bad idea.


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Aug 18 2017, 12:45 AM
Post #5


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE(Christian J @ Aug 17 2017, 05:23 AM) *
But see also http://webtips.dan.info/subdir.html#FinalSlash on why it may be a bad idea.
This bears repeating.

The URLs .../cinema/ and .../cinema/index.html are at the same level when it comes to relative links, and they're practically interchangeable.

The URL .../cinema is at a different level when it comes to relative links, and it is not interchangeable with the other two.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
matthewhunt
post Aug 19 2017, 11:20 PM
Post #6





Group: Members
Posts: 9
Joined: 15-February 07
Member No.: 1,910



QUOTE(Darin McGrew @ Aug 18 2017, 12:45 AM) *

QUOTE(Christian J @ Aug 17 2017, 05:23 AM) *
But see also http://webtips.dan.info/subdir.html#FinalSlash on why it may be a bad idea.
This bears repeating.

The URLs .../cinema/ and .../cinema/index.html are at the same level when it comes to relative links, and they're practically interchangeable.

The URL .../cinema is at a different level when it comes to relative links, and it is not interchangeable with the other two.


That's very clear. Is it therefore possible to create an HTML file that can be accessed via the URL .../cinema ? (For example, the BBC News site has URLS such as bbcnews.com/uk and bbcnews.com/sport etc that link to files rather than directories.) Or is this done simply with a redirect?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Aug 20 2017, 12:43 AM
Post #7


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE(matthewhunt @ Aug 19 2017, 09:20 PM) *
Is it therefore possible to create an HTML file that can be accessed via the URL .../cinema ? (For example, the BBC News site has URLS such as bbcnews.com/uk and bbcnews.com/sport etc that link to files rather than directories.) Or is this done simply with a redirect?
One way to do it is content negotiation, as described near the end of https://www.w3.org/Provider/Style/URI
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 20 2017, 10:05 AM
Post #8


.
********

Group: WDG Moderators
Posts: 9,628
Joined: 10-August 06
Member No.: 7



QUOTE(Darin McGrew @ Aug 18 2017, 07:45 AM) *

The URLs .../cinema/ and .../cinema/index.html are at the same level when it comes to relative links, and they're practically interchangeable.

The URL .../cinema is at a different level when it comes to relative links, and it is not interchangeable with the other two.

Let's see if I got this right. If the URL .../cinema retrieves the HTML file .../cinema/index.html, then relative links in that file such as

CODE
<a href="foo.html">foo</a>

will not resolve to .../cinema/foo.html, but to .../foo.html --is that correct? So basically you can't use relative URLs in some of your links, but must instead use absolute URLs?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 20 2017, 10:23 AM
Post #9


.
********

Group: WDG Moderators
Posts: 9,628
Joined: 10-August 06
Member No.: 7



Regarding how to actually configure the content negotiation I can't find much in the way of tutorials, but here's one at least:
http://www.websiteoptimization.com/speed/tweak/rewrite/

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Aug 20 2017, 11:54 AM
Post #10


WDG Member
********

Group: Root Admin
Posts: 8,365
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



QUOTE(Christian J @ Aug 20 2017, 08:05 AM) *

QUOTE(Darin McGrew @ Aug 18 2017, 07:45 AM) *

The URLs .../cinema/ and .../cinema/index.html are at the same level when it comes to relative links, and they're practically interchangeable.

The URL .../cinema is at a different level when it comes to relative links, and it is not interchangeable with the other two.
Let's see if I got this right. If the URL .../cinema retrieves the HTML file .../cinema/index.html, then relative links in that file such as

CODE
<a href="foo.html">foo</a>
will not resolve to .../cinema/foo.html, but to .../foo.html --is that correct? So basically you can't use relative URLs in some of your links, but must instead use absolute URLs?
Pretty much.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th March 2024 - 02:24 AM