tildeclub/tilde.club

.htaccess

Closed this issue · 12 comments

Has anyone gotten .htaccess files to work? I tried a few things, but in the best cases it seems to have no effect (e.g., custom 404 page) and worst cases it causes ISE (e.g., disabling directory browsing). I see a bunch of people have added .htaccess files, but I checked a couple out and they don't seem to actually be having any effect. Anyone have one that's actually confirmed working?

So they definitely work, inasmuch as this URL is protected by HTTP basic auth that's enabled in an .htaccess file in the directory.

Looking at the server config, the relevant line for user directories is AllowOverride FileInfo AuthConfig Limit. Docs for the AllowOverride configuration directive are here which explain what the presence of the FileInfo, AuthConfig, and Limit options means in terms of what you can do in your local .htaccess files.

OK, thanks. I should have thought to test that, too. The issue some people are trying to solve is having index.shtml work in addition to index.html. From what I can see, some people have it working for their public_html folder, but not for sub directories. If you know any quick fix off the top of your head, let me know. Otherwise, I'll sort out another time.

So mod_rewrite should work; the following is what I have in the .htaccess within this subdirectory of my public_html dir and it works to redirect requests for the default index page of each directory to index.shtml within that directory:

RewriteEngine On
RewriteBase /~delfuego/test2/
RewriteRule ^$ index.shtml
RewriteRule ^(.*/)$ $1index.shtml

I'll note, though, that including the Indexes option in the per-user-directory AllowOverride would make this all a hella lot easier:

DirectoryIndex index.shtml

Let me mull that over...

That's helpful, thanks.

DirectoryIndex index.shtml
Right, that's what's causing ISE.

@delfuego From what I can tell DirectoryIndex will still allow multiple index files

e.g. DirectoryIndex index.html index.shtml index.txt and so on.

Oh, yeah, I know @michaelcoyote — I just want to make sure I think through whether there are any unanticipated side effects of enabling AllowOverride Indexes on the server.

Offhand, I can think that one side-effect will be that any home pages that aren't index.html aren't going to show up in the recently-updated list — that's generated server-side by looking at the mod times of users' root index.html files, and there's no good filesystem-based way to modify that to take into account changes people make to their DirectoryIndex settings.

Isn't that an issue regardless of whether one uses mod_rewrite or
DirectoryIndex (or anything else, such as meta redirect)?

To give some context, that reason for .shtml is simply for server side
includes. In case you have other ideas for how to include files on the
server side without SSI.

@delfuego Is AllowOveride indexes now required to use multiple DirectoryIndex settings? Honest question here, my ApacheFu is super rusty and at least 1 major version out of date, but it didn't used to be so. It's also possible I am misunderstanding the issue.

In the end, I feel if we can save any user from having to touch mod_rewrite, I think it would be good. Some things should stay in the past :-\

@michaelcoyote Yes, you can't use DirectoryIndex in an .htaccess file without us making a change to the server settings to allow it; that server setting is to include the Indexes option in the per-user-directory AllowOverride configuration parameter.

And yes, no matter how a user changed the default index page for their main user directory (DirectoryIndex, mod_rewrite, whatever), they'd be making it invisible to the recently-updated script. And there's really no way to fix that without going to an HTTP mechanism for checking users' home pages and maintaining a not-inconsiderable amount of state — we'd be talking about essentially building a brand new web crawler.

Yes, you can't use DirectoryIndex in an .htaccess file without us making a change to the server settings to allow it; that server setting is to include the Indexes option in the per-user-directory AllowOverride configuration parameter.

Ah, so I was misunderstanding it.. I was suggesting a change of the DirectoryIndex parameter at the server configuration level. It seems like it would be the least amount over overall change to the system and allow users more flexibility without having to resort to mod_rewrite and hacking with .htaccess files

I can't comment on the crawler. I know it's important, but it seems like if people are going to be having their index page be a static page that redirects them to whatever fun thing they're actually updating, It'll all end in tears, anyhow.