如何编辑 .htaccess 以将子域重定向到端口 8080

how edit .htaccess to refirect subdomain to port 8080

在我的网站上 site.com 我有一个子域 subdomain.site.com 我在端口 subdomain.site.com:8080 上有服务 如何将所有用户从 subdomain.site.com 重定向到 subdomain.site.com:8080

我想编辑我的 .htaccess

此代码应该有效:

# If we are on the subdomain
RewriteCond %{HTTP_HOST} ^subdomain.site.com$

# If the port isn't 8080
RewriteCond %{SERVER_PORT} !^8080$

# We redirect to the same adresse with the port
RewriteRule ^(.*)$ http://%{HTTP_HOST}:8080/ [R=301,L]