Search code examples
apachemod-rewritemultiviews

.htaccess RewriteRule Issue with Mac OSX server, not present on Unix server


I'm working on an aircraft website and using a .htaccess file to rewrite the URLS so they are seo friendly. Here is the file:

AddType application/x-httpd-php /(.*)
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^general-aviation-models/(.*)/(.*) /models.php?mfg=$1&model=$2
RewriteRule ^general-aviation/(.*)/(.*) /general.php?page=$1&sub=$2
RewriteRule ^general-aviation/(.*)  /general.php?page=$1
RewriteRule ^general-aviation  /index.php
RewriteRule ^military/(.*) /military.php?page=$1
RewriteRule ^military-models/(.*)/(.*) /military-models.php?mfg=$1&model=$2
RewriteRule ^military-models/(.*) /military-models.php?mfg=$1
RewriteRule ^cart/ /cart.php
RewriteRule ^contact/ /contact.php
RewriteRule ^commercial/(.*)/(.*) /commercial.php?page=$1&sub=$2
RewriteRule ^commercial/(.*)  /commercial.php?page=$1
RewriteRule ^commercial/ /commercial.php
RewriteRule ^links/ /links.php
RewriteRule ^about/ /about.php
RewriteRule ^tour/(.*)  /tour.php?page=$1
RewriteRule ^tour/ /tour.php

ExpiresDefault "access plus 10 years"
AddOutputFilterByType DEFLATE text/plain

This has worked on a *nix-based server as well as on MAMP in my local development environment, however upon migrating to a Mac OSX server, several (but not all) of the rules fail. In particular, these fail:

RewriteRule ^military-models/(.*)/(.*) /military-models.php?mfg=$1&model=$2
RewriteRule ^military-models/(.*) /military-models.php?mfg=$1
RewriteRule ^commercial/(.*)/(.*) /commercial.php?page=$1&sub=$2
RewriteRule ^commercial/(.*)  /commercial.php?page=$1

Other notes:

  • the mod_rewrite module successfully loads (shows up in the Loaded Modules section of phpinfo())
  • I have AllowOverride All in my httpd.conf file (in appropriate tags)
  • my server API is Apache 2.0 Handler

I have looked around SO for a while but haven't found much. I tried the first solution in this SO question but the added line caused this error in my logs:

/my_specific/document_root/.htaccess: DocumentRoot not allowed here

Any suggestions?

UPDATE:

Turns out Apache's Multiviews feature was turned on which ended up working for most of my rewriterules anyway, but was overriding them and caused the 4 failures listed. All I had to do was add this to the top of my htaccess file:

Options -MultiViews

Solution

  • Turns out Apache's Multiviews feature was turned on by default which ended up working for most of my rewriterules anyway, but was overriding them and caused the 4 failures listed. All I had to do was add this to the top of my htaccess file:

    Options -MultiViews