Attempting to expand on @Zoredache's answer, as I give this a go myself:
Create a new group (www-pub) and add the users to that group
groupadd www-pub
usermod -a -G www-pub usera
## must use -a to append to existing groups
usermod -a -G www-pub userb
groups usera
## display groups for user
Change the ownership of everything under /var/www to root:www-pub
chown -R root:www-pub /var/www
## -R for recursive
Change the permissions of all the folders to 2775
chmod 2775 /var/www
## 2=set group id, 7=rwx for owner (root), 7=rwx for group (www-pub), 5=rx for world (including apache www-data user)
Set group ID (SETGID) bit (2) causes the group (www-pub) to be copied to all new files/folders created in that folder. Other options are SETUID (4) to copy the user id, and STICKY (1) which I think lets only the owner delete files.
There's a -R
recursive option, but that won't discriminate between files and folders, so you have to use find, like so:
find /var/www -type d -exec chmod 2775 {} +
Change all the files to 0664
find /var/www -type f -exec chmod 0664 {} +
Change the umask for your users to 0002
The umask controls the default file creation permissions, 0002 means files will have 664 and directories 775. Setting this (by editing the umask
line at the bottom of /etc/profile
in my case) means files created by one user will be writable by other users in the www-group without needing to chmod
them.
Test all this by creating a file and directory and verifying the owner, group and permissions with ls -l
.
Note: You'll need to logout/in for changes to your groups to take effect!
I don't know what exactly defines a "maintenance nightmare" in your book, but you could try to go with a dynamic rewriting map in apache:
RewriteEngine on
RewriteMap vanity-map prg:/path/to/vanity.pl
RewriteRule ^/(.*)/(.*)$ /${vanity-map:$1}/$2
vanity.pl could could be a simple perl script (don't forget to set $| = 1;
) which gets the first part of the request URL (as outlined above) on STDIN
and is supposed to rewrite that - e.g. by querying a database.
Now, that just leaves the frontend. I'm an inexperienced Ruby on Rails programmer (it's just a spare time activity), but I think, if it doesn't need to look pretty, even I could write an application that authenticates a user, lets him create a rewriting and shows that up for approval to some IT guys/$WHATEVER in much less than a week, so I don't think any real programmer would have a problem doing that in a few hours. Depending on the database, there might even be frontends readily available which will do the job with only a little customization (php*admin comes to my mind).
This way, you get all the flexibility of a database approach paired with a central source for all redirections. As long as the database's index on the URL part fits in your servers memory, you won't even have to worry about performance.
Best Answer
You can use
Include
directive inhttpd.conf
to be able to maintain redirects in another file. But it would not be very efficient, as every request would need to be checked against a lot of regular expressions. Also a server restart would be required after every change in the file.A better way for so many redirects would be to use RewriteMap directive of type
dbm
to declare a map from URI's to redirects. This way it will be efficient, as dbm lookups are very fast, and after a change in the map you would not need to restart a server, ashttpd
checks for map file modification time.A rewrite rules would look like this (tested on my Fedora 16 computer):
And dbm map would be created from text map
/etc/httpd/conf/redirects.txt
looking like this:using a command