mod_rewrite not working in user folders?

Hi everybody,

I experience a odd problem and maybe somebody can help. I use a 10.5.8 OS X Server running Apache with PHP 5.3.0.3 entropy update and all works fine.

Today I tried to create .htaccess file to redirect some http requests, also known as url rewriting using mod_rewrite.so. I tried to create a file in /Library/WebServer/Documents with this content:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+) index.php?site=$1 [L]

and a index.php file with this content:
<pre>
<?
print_r($_REQUEST);
?>
</pre>

This prints, whatever was given as parameter to my page… as expected.

Little later i wanted to use the very same files in my User Folder, which is based in /Volumes/Users/Userdata/username/Sites/ and it does not work, the url rewriting does not work and I always get 404 message. Looks like the Rewrite Rules never get loaded…

Is there any way to enable url rewriting for Users? Where is the config file that forces an "AllowOverride None" for my users? Any ideas?

I had a similar problem with php earlier on, which was parsed php files in the main document directory but not within user folders… odd enough, the default configuration(no php.ini loaded) does not cause this kind of problem, but if i load a php.ini eg. php.ini-recommended no filles will be parsed in my users sites directory.

this is not unique to my user account and affects all users on the server 😟

any ideas?

xServe, Mac OS X (10.5)

Posted on Aug 3, 2010 4:26 PM

Reply
2 replies

Aug 3, 2010 8:51 PM in response to K.OS

This just sounds like a classic Apache configuration question.

By default (at least in Apple's default configuration - I have no idea what Entropy do to the configs), .htaccess files are disabled (for both security and performance reasons).

In this case, since the .htaccess rewrites work in your root directory it sounds like someone has enabled .htaccess there but haven't done for the user's home directories.

In order for rewrites to work in a .htaccess file the directory needs the FileInfo override set. This is typically done in a <Directory> declaration in your config file, like:

<Directory "/Volumes/Users/Userdata/username/Sites">
AllowOverride FileInfo
</Directory>


This tells Apache to permit FileInfo-based commands in a .htaccess file in the specified directory.

Just make sure you trust your users, though - putting too much power in the hands of your users could compromise your server security.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

mod_rewrite not working in user folders?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.