Apple Event: May 7th at 7 am PT

Newsroom Update

Beginning in May, a special Today at Apple series titled “Made for Business” will offer small business owners and entrepreneurs free opportunities to learn how Apple products and services can support their growth and success. Learn more >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

mod_rewrite not working for virtual host nor .htaccess

I've been tearing my hair out trying to implement mod_rewrite on my Leopard Server. I have finally been able to get mod_rewrite to log what it does, but that has only shown that it DOES periodically respond to a /server_status request from the server itself, but any request to the virtual host (which is otherwise working) does not result in mod_rewrite being 'triggered.' I've tried all the usual suspects, in just about every permutation and combination:


1) .htaccess in all its guises and Override All;


2) RewriteEngine On;


3) http.conf, the virtual xxxx_80_virtualhostname.com.conf;


4) Options All -Includes -ExecCGI +MultiViews -Indexes +FollowSymlinks;


5) other less credible ideas gleaned from the Apple discussions and the web.


If I had to summarise the effect, it's that


a) mod_rewrite is on (as shown by the regular /server_status entries in the rewrite.log);


b) xxxx_80_virtualhostname.com.conf is read when the virtual host is turned on (because the site is active and can be turned off, at will);


c) any mod_rewrite and Options entries in the vistual host xxxx_80_virtualhostname.com.conf seem to be being studiously ignored, even though the .conf file is being read and used.


This part of http.conf is what seems to turn on the logging:


<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteLog /private/var/log/apache2/rewrite.log
     RewriteLogLevel 9
</IfModule>

Here's the section of xxxx_80_virtualhostname.com.conf:


<Directory "/Library/WebServer/com.VirtualHostName">
     AllowOverride All
     <IfModule mod_dav.c>
          DAV Off
     </IfModule>
     Options All -Includes -ExecCGI +MultiViews -Indexes +FollowSymlinks
</Directory>
<IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteLog /private/var/log/apache2/rewrite.log
     RewriteLogLevel 9
     RewriteRule ^/Tom.html$ /Mary.html [R]
     RewriteCond %{REQUEST_METHOD} ^TRACE
     RewriteRule .* - [F]
</IfModule>


This is a variant of the .htaccess file:


RewriteEngine on
RewriteBase /
RewriteRule ^/Tom.html$ /MARY.html [R]

It makes no difference whether the RewriteBase is present in the .htaccess or the xxxx_80_virtualhostname.com.conf, or both.


No amount of pass-though [PT] or redirect [R] has any effect, either.


I do have Lasso 8.5 installed, but the developer says that Lasso should have no effect on the proper functioning of mod_rewrite.


mod_rewrite is working (i.e. it's on, as shown by the /server_status entries in the log and that the log is being updated), but it is also not working (in that no matter what I put into xxxx_80_virtualhostname.com.conf and/or .htaccess, there is no entry in the rewrite.log nor in the system logs).


Hence, I'm stumped. Any suggestions would be very, very welcome. 🙂

Posted on Apr 9, 2012 9:06 AM

Reply
Question marked as Best reply

Posted on Apr 11, 2012 12:41 PM

⚠ Never mind. I discovered that Server had created several versions of the virtual host .conf file in the sites folder (I've no idea why, when, or how it would do that). They all had different numbers and so were well hidden within the dozens of other .conf files. Once I a) found the right .conf file for the virtual host, and b) deleted the rest from the sites folder, my mod_rewrite code worked fine. 🙂


Hence, if you find that mod_rewrite is working, but not for a particular virtual host, make darn sure that there are no errant .conf files for the domain and, if there are, that you're editing the correct one. 😐

1 reply
Question marked as Best reply

Apr 11, 2012 12:41 PM in response to Trevor Jacques

⚠ Never mind. I discovered that Server had created several versions of the virtual host .conf file in the sites folder (I've no idea why, when, or how it would do that). They all had different numbers and so were well hidden within the dozens of other .conf files. Once I a) found the right .conf file for the virtual host, and b) deleted the rest from the sites folder, my mod_rewrite code worked fine. 🙂


Hence, if you find that mod_rewrite is working, but not for a particular virtual host, make darn sure that there are no errant .conf files for the domain and, if there are, that you're editing the correct one. 😐

mod_rewrite not working for virtual host nor .htaccess

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