- This topic has 2 replies, 3 voices, and was last updated 19 years, 2 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.
Home › Forums › Archives › Computer Support › Computer Support Discussion › .htaccess and dynamic index files
Question for you Apache gurus out there…
Is there a way to use mod_rewrite to set the default file for a directory?
For example, in my “journal” directory, I have this line in the .htaccess file:
DirectoryIndex journal.php
That way I can see at a glance what that file is for, and it’s harder to accidentally overwrite an index file (easy to do when they’re all named index.php). The downside is that I have to do that for every folder, which makes it a pain to maintain. Is there a way to maybe use a rewrite rule to do this from a master .htaccess file?
.htaccess files are only needed when you don’t have access to your apache configuration (i.e. are on a shared server … basically don’t have access to the account that runs apache).
anyway… what you could do in httpd.conf (or in the main .htaccess) is type this
DirectoryIndex 1file.cool 2file.cool 3file.cool 4file.cool
^ idea from ONLamp.com — An Amble Through Apache Configuration
that would make apache look for 1file.cool (one of your directories main files) first then the second and third…etc which would work but its sorta workaround. i don’t know much about mod_rewrite though… so i can’t help you there.
(I thought I replied to this yesterday…)
If the DirectoryIndex keyword isn’t inherit from the parent directory, then you’re pretty much SOL unless you can get access to your httpd.conf as RUSD said.
Now as for using mod_rewrite, I think you could setup some stupidly complex thing where your data is stored in /real/folderName, then accessed by /folderName, and rewrite would find the path, check for the journal.php, and execute it… but that’s a pretty ugly hack.