0
votes

Here is my folder structure:

Root/
sub.domainname.com/
 .htaccess
 app/
  .htacess
  webroot/
   .htacess
httpdocs/
 .htaccess

I'm trying to set up a subdomain for my application but server return error:500 when I call sub.domain.com

I think I config .htaccess incorrect and I have no idea to fix it to work! help me please.

*in httpdocs folder is main web files on domain >> www.domainname.com but files in this folder not Cakephp framework it's use Wordpress and in sub.domainname.com is subdomain web files to use Cakephp framework.

*I use shared hosting (http://netdesignhost.com/) lookalike GoDaddy Hosting.

Dear Variables and all ... this my .htaccess

cakephp/.htaccess

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

cakephp/app/.htaccess

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

cakephp/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /app/
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    RewriteCond %{REQUEST_URI} !^/(app/webroot/)?(img|css|js)/(.*)$
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

This's error logs

[Sun Sep 17 23:38:45 2017] [alert] [client 184.22.122.56] /var/www/vhosts/domain.com/sub.domain.com/.htaccess: RewriteRule: bad flag delimiters, referer: http://sub.domain.com/

[Sun Sep 17 23:42:18 2017] [error] [client 184.22.122.56] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

thank you. Pea.

1
Please post the content of cakephp/.htaccess, cakephp/app/.htaccess and cakephp/app/webroot/.htaccess and your http error logs, since HTTP Status Code 500 is a generic error message. Most likely the RewriteBase is not set correctly.polyte
I post new answers already thank for reply me : ))Life of Pea lo ma
Variables , I posted my .htaccess and error logs do you have idea :))Life of Pea lo ma
I'm not sure here; Try to remove the RewriteBase /app/ from both files and test. If this is not working try to remove RewriteCond %{REQUEST_URI} !^/(app/webroot/)?(img|css|js)/(.*)$ for debugging.polyte

1 Answers

0
votes

It might be a good idea to start with a simple 'hello world' HTML page in what you think is the subdomain root, and put is there on its own, to make sure the subdomain works properly before adding in anything else.

Another issue is: most servers I've seen would need the folder structure to be slightly different:

Root/
 sub.domainname.com/
  httpdocs/   /* sub-domain site */
   .htaccess
   app/
    .htacess
    webroot/
     .htacess
 httpdocs/ /* main site */
  .htaccess

So instead of putting all your subdomain code (.htaccess and app folder) directly into the subdomain folder, you put it into an httpdocs folder inside the subdomain folder. But do try with just a simple HTML file first.