Site icon Hip-Hop Website Design and Development

Redirect from different port to subdomain – htaccess

I created a Digital Ocean instance to install WordPress website 5 days ago. I already have my own domain, and created DNS Subdomain blog.example.com. The server runs both nginx and apache so my Apache port is 8082. Below is what my actual WordPress URL looks like:

www.example.com:8082/wordpress/

Something which I have tried is below.

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?example.com:8082/wordpress
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([a-z0-9-]+)/? http://$1.example.com [R=301,NC,L]

</IfModule>

Now my expected result is from

www.example.com:8082/wordpress 

to

blog.example.com