0

I would like to make a rule for a subdomain, so my teamspeak subdomain will directly be redirected to the ts3 protocol.

So, let me show you an example:

RewriteCond %{HTTP_HOST} ^(ts\.)?example\.com$ [NC]
RewriteRule ^(.*)$ ts3://example.com/$1 [R=301,L]

Unfortunately, this isnt working (resulting an endless loop).

To be honest, I've no experience with .htaccess. What should it look like? Tried some other examples, but most of them just rewrite into a directory or redirect to another domain, so I am lacking of examples...

Is it even possible to do what I'm trying?

1

TL;DR .htaccess aren't made for that, and TS3 wouldn't understand Apache's HTTP traffic (for many protocol-related reasons). The best solution is probably to make ts.example.com an alias to example.com (in your domain's DNS configuration), and to ask your clients to connect to ts.example.com:x where x is your Teamspeak connection port.

.htaccess files are used by the Apache web server. It is part of a system which handles HTTP traffic. Teamspeak 3 does not understand HTTP traffic... because it's not an HTTP server. Therefore, redirecting HTTP traffic to TS3 with an .htaccess file (assuming it was the right way to do so) would not make much sense: TS3 would just discard the requests, since it can't understand HTTP requests.

The Teamspeak service is associated to a port, not an address. If you use netstat, you'll actually be able to find that port. I'm not very familiar with Teamspeak, but I heard of ports 9987 and 10011... You'd have to check your TS3 configuration for that :)

If you want to redirect everything coming in from ts.example.com to example.com, I'd simply recommend that you configure your domain name to work that way. Make ts.example.com an alias to example.com, and all requests sent to ts.example.com:9987 will arrive at example.com:9987. This kind of configuration is usually handled by your authoritative name server, and you should have access to DNS zones management in order to apply your changes.

Now, redirecting all traffic coming from the ts.example.com to port 9987 specifically is more complicated, and it is also very counterproductive. Teamspeak uses several ports (queries, voice data, file transfers...) : if you send everything to 9987, then it might not receive queries and file transfers, possibly making the initial connection impossible. Besides, your machine will not be able to distinguish traffic coming from ts.example.com of that coming from example.com, since the client reached it by IP after resolving the name.

An HTTP server (or maybe, proxy) could indeed make that distinction using the HTTP Host header, but there are so many protocol-related issues to deal with here:

  • HTTP is connection-based, the traffic would have to be transported from TCP to UDP (hello overhead!).
  • The Host: header would have to be remove so that only the TS3 binary data remains. Mixing text and binary data is, of course, a terrible idea.
  • The proxy would also have to be able to distinguish voice data from file transfers and TS3 queries... and I'm pretty sure such a proxy does not exist.
  • ...
  • The reason why I wanted to do this, I want to open teamspeak, when i use that subdomain. It can be easily done by inserting the following url ts3server://mydomain.de?port=9987. I have already made a ts. subdomain in my dns settings, so I thought, whenever I use that subdomain, I wanted the same behaviour as I used the link ts3server://mydomain.de?port=9987 – Jannik Aug 12 '15 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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