.htaccess and mod_rewrite

I had apache working well in Tiger with my .htaccess file rewrting my urls with...
<pre>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* ./_urlHandler.php [L]
</pre>

After upgrading to Leopard I cannot seem to get it to work. I am looking in the /etc/apache2 directory, and I have updated the conf file with:

<pre>
<Directory "/Users/username/Sites">
Options Indexes MultiViews Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</pre>

I have also added these lines to /etc/apache2/users/username.conf

Any ideas on why mod_rewrite won't work. I thought it had to do with MultiViews.

MacBook Pro 2.33GHz, Mac OS X (10.5.1), 120GB 2GB

Posted on Nov 30, 2007 6:20 PM

Reply
3 replies

Dec 1, 2007 4:41 AM in response to Eric Blankfield

I'm curious if anyone else has had mod_rewrite trouble since upgrading to 10.5. It definitely seems to be something to do with mod_rewrite. I know apache is reading my .htaccess file, because if I throw some gibberish in it, I get a 500 error. If I throw an exit; or echo "Blah"; in the files that mod_rewrite is supposed to rewrite to, nothing happens.

(LoadModule rewrite_module libexec/apache2/mod_rewrite.so is uncommented)

Dec 1, 2007 8:14 PM in response to Eric Blankfield

Just throwing it out there, just in case anyone is following this. Mod rewrite is working. I did find a small issue where Apache 2.2.6 isn't returning SCRIPT_URI (itself an internal apache concatenation of other environment variables) but that can be, and was, dealt with. What seems to be happening is that PHP is not passing $GLOBALS from the rewritten script to the requested script anymore.

I have checked, and my previous version of php.ini, as well as that on the server has register_globals turned off. It worked that way before. I'm not using global $var = 'somevalue'. I'm using $GLOBALS\['var'\] = 'somevalue'. It worked very well, and continues to work on the production server. I CAN however declare $GLOBALS\['var'\] = 'somevalue' locally, but if I try to carry it across from the rewritten script to the requested script, it fails on Leopard's Apache 2.2.6.

I might install 1.3 or 2.0.x to see if that solves it. 😐

Dec 2, 2007 4:39 AM in response to Eric Blankfield

Update.

It isn't $GLOBALS, but constants that aren't being passed through. Must be some php.ini setting I'm not aware of. I was using both $GLOBALS and define() to try passing the values through. In the request script, I was calling the constants, which were being passed through before Leopard, but after the upgrade, they aren't. I solved the problem by simply referring to the $GLOBALS, but I'd like to know which setting it is that has changed, just for grins.

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.

.htaccess and mod_rewrite

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