I'm trying to redirect an application link, but the middle colon (:) was not added. It's probably a simple problem but I couldn't find a solution.
Currently, I have the following .htaccess:
RewriteEngine on
RewriteRule ^(.*)$ http://ts3server://ts3.domain.com [R=301,L]
Result:
http://ts3server//ts3.domain.com
From comments, it would seem the intention is to redirect to
ts3server://ts3.domain.com
(ts3server
is the intended protocol, nothttp
as stated in your rule).In this instance the limitation is mod_rewrite (not Apache per se).
ts3server
is not a protocol that mod_rewrite understands and since the substitution string does not start with a slash it is seen as a relative URL-path and so (by default) the directory-prefix (ie./home/domain/web/domain.co/public_html/
) is added back when constructing the URL to redirect to (in theLocation
header).The solution is to use a mod_alias
Redirect
orRedirectMatch
directive instead, that doesn't "validate" the protocol.Your rule appears to suggest that everything should be redirected to a single target (many-to-one) - which doesn't look correct, but if that is the intention then use
RedirectMatch
. For example:(Should there be a trailing slash on the end of the target URL?)
Otherwise, if the intention is to redirect
/something
tots3server://ts3.domain.com/something
then use aRedirect
directive instead, that uses simple prefix matching (automatically copying the match onto the end of the target). For example:(Note the trailing slash on the target - mandatory in this example, otherwise you will get a malformed redirect for anything but requests to the root.)
Make sure you clear your browser cache before testing and test first with a 302 (temp) redirect to avoid potential caching issues.