removing .html extension in folders |
removing .html extension in folders |
matthewhunt |
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. |
Christian J |
Aug 17 2017, 05:56 AM
Post
#2
|
. Group: WDG Moderators Posts: 9,739 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. |
matthewhunt |
Aug 17 2017, 06:23 AM
Post
#3
|
Group: Members Posts: 9 Joined: 15-February 07 Member No.: 1,910 |
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? |
Christian J |
Aug 17 2017, 07:23 AM
Post
#4
|
. Group: WDG Moderators Posts: 9,739 Joined: 10-August 06 Member No.: 7 |
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. |
Darin McGrew |
Aug 18 2017, 12:45 AM
Post
#5
|
WDG Member Group: Root Admin Posts: 8,366 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
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. |
matthewhunt |
Aug 19 2017, 11:20 PM
Post
#6
|
Group: Members Posts: 9 Joined: 15-February 07 Member No.: 1,910 |
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? |
Darin McGrew |
Aug 20 2017, 12:43 AM
Post
#7
|
WDG Member Group: Root Admin Posts: 8,366 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
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 |
Christian J |
Aug 20 2017, 10:05 AM
Post
#8
|
. Group: WDG Moderators Posts: 9,739 Joined: 10-August 06 Member No.: 7 |
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? |
Christian J |
Aug 20 2017, 10:23 AM
Post
#9
|
. Group: WDG Moderators Posts: 9,739 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/ |
Darin McGrew |
Aug 20 2017, 11:54 AM
Post
#10
|
WDG Member Group: Root Admin Posts: 8,366 Joined: 4-August 06 From: Mountain View, CA Member No.: 3 |
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. 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? |
Lo-Fi Version | Time is now: 10th November 2024 - 02:23 PM |