0

I am about to move my html files from the root folder to a couple of subfolders.

The default setting my host is using is to show the trailing slash for the subfolders and no slash for the html files. If the browser requests a subfolder without trailing slash, a 301 redirect to the same folder with trailing slash is returned. The files are shown without html extension thanks to a .htaccess snippet.

I think I like the approach to distinguish the subfolders from the files. In my case the contents of the index files will be different than the ordinary files.

However, I am not as convinced as many others that duplicate content is a disaster. I cannot be sure how my websites will develop in the future and what I will think about trailing slashes and such, so an easy forward compatible strategy is therefore desirable. For that reason I am considering to abandon the 301 redirect and instead allow the browser to send urls to subfolders both with and without the trailing slash and with response 200 OK in both cases. Yes, that leads to duplicate content, but I will will keep the trailing slash on all subfolders on all internal and canonical links, so in practice, I do not think it is a disaster. And Google and Bing and others should be able to figure things out.

I have my sites on a shared server configured via directadmin and (probably) no access to other configuration files and do not know how the default setting has been accomplished. I guess I need to do something in .htaccess to change the default setting but I am not sure what.

Is there anybody who knows how to override the default setting so that I get rid of the 301 redirect in the mentioned case and instead send 200?

I found this interesting document https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryindex , but I can not interpret it, and I do not dare to do any trial and error. Hope that somebody can give me a hint.

joed
  • 1
  • You almost found it - you are looking for the `DirectorySlash` directive, mentioned on that same documentation page. Pay attention to the security warning though. – CBroe Dec 13 '22 at 07:36
  • I don't see what you think you'd actually be gaining by this though. – CBroe Dec 13 '22 at 07:37
  • Thanks for your comment. I was seeking a way to be able to change strategy in the future by just update internal and canonical links without having to bother about tricky .htaccess snippets. I have read about `DirectorySlash` and the security warning and that is one of the reasons why I prefer a simpler way. – joed Dec 13 '22 at 09:12

0 Answers0