Page 1 of 1

How redirect subdomain.example.com to example.com:port

Posted: Thu Feb 08, 2018 6:39 am
by Rhodwulf
Hi....

I have an issue, i created a subdomain for my irc server,and i want to redirect all the traffic from irc.example.com to example.com:ircport , because i have a webirc installed on my site.

I configured a .htaccess file and dont work, i try a redirect since an index.php and index.html and dont work.

┬┐Why if i create a subdomain this redirect me to the folder of the principal domain?


Thanks in advance.

Re: How redirect subdomain.example.com to example.com:port

Posted: Thu Feb 08, 2018 11:11 am
by putude
I don't know is it work or not, but you may try it.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^irc.example.com$ [NC]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ http://example.com:ircport$1 [R=301,L]

Re: How redirect subdomain.example.com to example.com:port

Posted: Thu Feb 08, 2018 5:41 pm
by Rhodwulf
Precisely it is the code that i used in the .htaccess file

I forgot to mention that if I write irc.example.com/index.html this show the default page of vesta, my doubt is still because irc.example.com redirects me to example.com and does not read the files in the folder.


Thanks.

Re: How redirect subdomain.example.com to example.com:port

Posted: Sat Feb 10, 2018 4:24 am
by noogen
Now you're making confusing statement. Did the redirect work? If so, then why do you care if index.html show the Vesta default?

If it didn't work, then did you put irc.example.com into the Aliases field of example.com? If you just point the DNS to IP address and didn't setup in the web panel/tab, then that's the reason why it's pointing to default Vesta index.

Also, are you setup with apache or nginx+php-fpm? .htaccess only work with apache. If you're on nginx+php-fpm and is seeing the redirect, then it may be your app that is redirecting. Example, you can set the default domain in Wordpress and it'll redirect for you without htaccess.