3

Currently I am using OSX Server (Yosemite) to host a bunch of PHP applications, some of which have a sub-directory under the websites document root for subdomains. Since updating to the Yosemite version of OSX Server, these subdomains have been throwing a 500 error with the error log referring to RewriteEngine not allowed here.

Investigating, I have confirmed that both the parent and subdomain sites have AllowOverride All configured, and .htaccess files are working on non-subdomain sites. Also, I have discovered that renaming or otherwise removing the .htaccess file from the parent directory causes the sub-domains to start working again.

/original_site_doc_root <- doc root for regular site
    .htaccess
    index.php
    ...
    subdomain/ <- configured as a seperate site in osx server as a subdomain
        .htaccess
        index.php
        ...

Every bit of googling I do ends up referring to making sure mod_rewrite is installed and AllowOverride is configured properly.

My question is, how can I get Apache to stop throwing a 500 error on the sub-domain sites?

Edit

Here is the .htaccess file for the sub-domain that is causing me grief (with domains, directories and pages fuzzed to protect the innocent)

RewriteEngine On
Options +FollowSymlinks -Indexes
RewriteCond %{HTTP_HOST} ^www\.m\.somesite\.com$ [NC]
RewriteRule ^(.*)$ http://m.somesite.com/$1 [L,R=301]
RewriteBase /

# supress php errors
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_value docref_root 0
php_value docref_ext 0

# enable PHP error logging
php_flag  log_errors on
php_value error_log  /some/fuzzed/dir

RewriteRule ^$ /index.php [L]
RewriteRule ^home$ /home.php [L]

RewriteRule ^some-page1$ /some-page1.php [L]

RewriteRule ^some-page2$ /some-page2.php [L]

RewriteRule ^some-page3/(.*)$ /some-page32.php [L]
RewriteRule ^some-page3(\/?)$ /some-page32.php [L]

RewriteRule ^some-page4/(.*)$ /some-page4.php [L]
RewriteRule ^some-page4(\/?)$ /some-page4.php [L]

RewriteRule ^some-page5/(.*)$ /some-page5.php [L]
RewriteRule ^some-page5(\/?)$ /some-page5.php [L]

RewriteRule ^some-page6/(.*)$ /some-page6.php [L]
RewriteRule ^some-page6(\/?)$ /some-page6.php [L]

The .htaccess for the parent directory/non-sub-domain-site is more or less similar, with the only real difference of relevance being the top 2 lines:

RewriteEngine On
Options +FollowSymlinks -Indexes -Multiviews
5
  • Are you using RewriteOptions InheritXXXX anywhere? The .htaccess file from the parent directory on the filesystem is inherited, although mod_rewrite is not normally.
    – MrWhite
    Commented Aug 19, 2015 at 1:32
  • both .htaccess files have RewriteEngine on and Options +FollowSymlinks -Indexes along with some pretty standard Rewrite rules and conditions. RewriteOptions InheritXXXX is neither in any of the .htaccess files or httpd_server_app.conf. Commented Aug 19, 2015 at 2:26
  • If you "remove" the .htaccess for the subdomain do you still get this error? (Granted your site probably doesn't work.) I think we'll probably need to see your .htaccess files (to rule out the obvious, if anything). What version of Apache?
    – MrWhite
    Commented Aug 19, 2015 at 8:06
  • have you resolved the problem in any way?
    – benck
    Commented Oct 23, 2016 at 11:07
  • "I have confirmed that both the parent and subdomain sites have AllowOverride All configured" - but where specifically are the AllowOverride All directives set? If AllowOverride All is only set in the parent domain's VirtualHost then you will need to redeclare this in the subdomain's own (isolated) VirtualHost as well.
    – MrWhite
    Commented Apr 5, 2018 at 0:12

2 Answers 2

2

Just ran into this same problem (after recent update Apache2) and found a solution.

Assume your domain is example.com and the directory is /var/www/example/, and you had a subdomain called api.example.com with directory /var/www/example/api/.

Try to use the following:

<VirtualHost *:80>
 ServerName api.example.com
 DocumentRoot /var/www/example/api

 <Directory /var/www/example/>
     AllowOverride FileInfo Options
 </Directory>

 <Directory /var/www/example/api/>
     Require all granted
     Options +FollowSymLinks +MultiViews +ExecCGI -Indexes
     AllowOverride all
     Order allow,deny
     Allow from all
 </Directory>

</VirtualHost>

This should work!

0

Since updating to the Yosemite version of OSX Server, these subdomains have been throwing a 500 error with the error log referring to RewriteEngine not allowed here.

OS X 10.10 (Yosemite) ships with Apache 2.4, whereas earlier versions of OS X ship with Apache 2.2. An important difference between these versions, and which is probably causing you problems, is that AllowOverride defaults to All in Apache 2.2 and None in Apache 2.4. (See the Apache Docs) You are perhaps relying on this default behaviour.

I have confirmed that both the parent and subdomain sites have AllowOverride All configured

But where exactly are the AllowOverride All directives set? I assume the parent and subdomain sites are configured as separate Virtual Hosts. If AllowOverride All is only set in the parent domain's VirtualHost, for the "parent directory" (of the subdomain), then this will not been seen when you access the subdomain, which is an entirely separate VirtualHost. You will need to redeclare this in the subdomain's own (isolated) VirtualHost as well (as in @benck's answer).

Or, if you don't want the parent .htaccess file to be processed at all then explicitly set the following in the subdomain's VirtualHost:

<Directory /var/www/example/>
    AllowOverride None
    AllowOverrideList None
</Directory>

.htaccess files work along the filesystem path, regardless of the host being accessed.

Alternatively, if the main domain is configured in the main server config (ie. not in a VirtualHost container) then you shouldn't have this problem, as the VirtualHost will inherit the server's configuration.

Reference:
https://en.wikipedia.org/wiki/MacOS_Server#OS_X_10.10_(Yosemite_Server_4.0)

Not the answer you're looking for? Browse other questions tagged or ask your own question.