A folder and a file with the same name in the same location [duplicate]
Solution 1:
The OS and file system do not allow this
Ubuntu and its file systems (ext3, ext4, etc.) doesn't allow an identically named file and folder in the same directory.
Therefore, nautilus
does not allow renaming a folder to an existing file name.
However, Ubuntu (GNU/Linux in general) file systems are case sensitive. You can have a folder called Articles and a file called articles in the same location. Note the folder name starts with a capital A
, while the file name starts with a small a
.
You can use any CaPiTaLiZaTion conventions you want for your folders and files.
An alternative
An alternative is to create a file called index.html
inside each folder where you want the folder and the file to have the same name. Naming your HTML file index.html
and putting them in a folder called e.g. example.com/articles/title
, so the full path is example.com/articles/title/index.html
, will also accomplish what you're asking.
When one types https://example.com/articles/title
the web server will serve the index.html
page and browsers won't show the index.html
. It will show only https://example.com/articles/title
.
Similarly, you can have a file called https://example.com/article/index.html
to show what you want when one types https://example.com/article
.
Thanks to Harry for the alternative and some other points.
Solution 2:
Question is a possible duplicate of https://stackoverflow.com/questions/34550299/aws-s3-hosting-url-rewrite. If you look in the comments, you'll even see that his precise use case is removing the .html from his URLs.
While the accepted answer provides a valid, working solution, I think this is a case of the XY problem. In this case, what you really need is a URL Rewriting system, which dispenses with the naming convention problem altogether. While the previous article does not apply to AWS S3, it explains the concept fairly well. Unfortunately, since S3 is not a web server per se, it doesn't have URL Rewrite functionality, but it does have Webpage Redirects which, as stated in the duplicate question's answer, might be able to do this.