Forum Moderators: phranque
Here is my situation I have two domain names hosted on one web server.
The primary domain aaa.com is located in
/home/me/public_html/
I also have a second domain which is an "add-on domain" (ie virtual host). It is located in a subdirectory:
/home/me/public_html/domaintwo
Now what I wanted to do was create a subdomain for domaintwo (sub.domaintwo.com) so i used my CPanel config to do this BUT my server is stupid and put the subdomain in
/home/me/public_html/sub
(But yes i can access it by going to sub.domaintwo.com)
Of course I wanted it in
/home/me/public_html/domaintwo/sub
(becuase it is a subdomain of domaintwo)
I cannot get my server admin to change this so I have to fix it with an htaccess file.
--------------
Here is what i tried:
1) First I put an htaccess in /home/me/public_html/sub
it looked like this:
RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} ^sub\.domaintwo\.com$
RewriteRule (.*) ../domaintwo/sub/$1
Unfortuately I get a "Invalid URI in request GET / HTTP/1.1" error. I assume i can't put ".." in the rewrite.
2)Next I tried to put an htaccess in my primary domains root - /home/me/public_html/
RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} ^sub\.domaintwo\.com$
RewriteRule (.*) /domaintwo/sub/$1 [L]
This did not work either: I got an Internal Server Error (and no new info in error logs).
3) Finally I tried putting an htaccess in /home/me/public_html/domaintwo/
RewriteEngine On
RewriteBase /RewriteCond %{HTTP_HOST} ^sub\.domaintwo\.com$
RewriteCond %{REQUEST_URI}!^/sub/
RewriteRule (.*) /sub/$1
This had no effect at all... I just got the directory listing of /home/me/public_html/sub
So now Im all out of ideas... If you know what i'm doing wrong please tell me :)
Thank you very much,
Andrew Krioukov
Welcome to WebmasterWorld [webmasterworld.com]!
Case 1 did not work because "../" is not valid in a server context - It has meaning only to a browser or to a shell command. The reason it is not supported in a server context is that it leads to too many security problems.
It is possible that case 2 did not work because your host is set up to disallow rewrites in the public_html directory in order to avoid conflicts with the code that cPanel generates.
Case 3 won't work because the .htaccess file is not in the directory path used to resolve the subdomain, as specified by the cPanel code.
You could try this in /sub
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub\.domaintwo\.com
RewriteRule (.*) /domaintwo/sub/$1 [L]
Note that I removed the end-anchor from the hostname pattern: This is necessary to support proxies which add the server port number to the hostname, i.e. sub.domain.com:80
Jim
I figured out that the error occurs only when I fill in the real values of sub and domaintwo in this line:
RewriteCond %{HTTP_HOST} ^sub\.domaintwo\.com
So i guess all that means is that it is not a syntax error its something that happens only when we try to redirect. Could it be that absolute paths (starting from root '/') are not allowed on my server?
Also do you have any other suggestions?
505 HTTP Version Not SupportedThe server does not support, or refuses to support, the HTTP protocol version that was used in the request message. The server is indicating that it is unable or unwilling to complete the request using the same major version as the client other than with this error message. The response SHOULD contain an entity describing why that version is not supported and what other protocols are supported by that server.
Jim