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,656 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,656 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,365 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. |
Christian J |
Aug 20 2017, 10:05 AM
Post
#6
|
. Group: WDG Moderators Posts: 9,656 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? |
Darin McGrew |
Aug 20 2017, 11:54 AM
Post
#7
|
WDG Member Group: Root Admin Posts: 8,365 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: 26th April 2024 - 09:21 AM |