.htaccess addon domain issue gives 500 error

1.2k views Asked by At

This is my .htaccess located at public_html

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

I have a (legacy) CakePHP app running in public_html/app for maindomain.com

I added an addon domain otherdomain.com under public_html/otherdomain. However, when trying to load the index page it returns a 500 server error.

Removing the public_html/.htaccess permits browsing otherdomain.com correctly, but the CakePHP app (maindomain.com) then has routing issues.

This is the CakePHP .htaccess under public_html/app:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]
 </IfModule>
1

There are 1 answers

0
Panama Jack On BEST ANSWER

it appears that your main htaccess is redirecting traffic to your app/webroot/ which is causing problems for otherdomain.com. Maybe you can check the hostname that is entered and redirect based on that. Something like this.

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteCond %{HTTP_HOST} ^maindomain\.com [NC] 
   RewriteRule    ^(.*)$ app/webroot/$1 [L]

   RewriteCond %{HTTP_HOST} ^otherdomain\.com [NC]
   RewriteRule    (.*) http://otherdomain.com/$1 [L]
</IfModule>