1

I want the visitors to sub.example.com to be redirected to

https://sub.example.com:9545

Is this possible with .htaccess? If so how should it look?

1 Answer 1

0

To "redirect" all visitors from sub.example.com to https://sub.example.com:9545, whilst maintaining the URL-path (I assume) then you could do something like the following in .htaccess using mod_rewrite:

RewriteCond %{HTTP_HOST} ^sub\.example\.com$
RewriteRule ^ https://%{HTTP_HOST}:9545%{REQUEST_URI} [R=302,L]

However, I wonder if you meant "rewrite" (as in internal redirect), rather "redirect" (as in external HTTP redirect) - do you wish the user to see the port?

If you wish the port to be hidden from the user then you can't simply rewrite the request, you need to configure your server as a reverse proxy and proxy the request to https://sub.example.com:9545 using mod_proxy. This does require some additional server configuration.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .