Avatar of daarchive
Flag for United States of America asked on

Redirect URL , Mask address, eventually will need to apply SSL

Hello All,

I am trying to do a redirect, which I have been able to do using the htaccess file, but I am having trouble meeting all of my requirements.

When users go to subdomain.domain.com, they need to be redirected to ip:8080/directory.

Address should be masked as subdomain.domain.com.

all directories for this site must be located using subdomain.domain.com/directories and there should be no imaging or access issues.

We will eventually need to add SSL to this, as it is a CRM site and the data needs to be protected.

Ive searched the net and found many articles where the code doesnt work.

Any help here is appriciated.

Thanks in advance.


Avatar of undefined
Last Comment

8/22/2022 - Mon

do want to do this with PHP or with apache's mod_rewrite?

here is how mod_rewrite can do it:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^8080$
RewriteCond %{HTTP_HOST} ^(subdomain.domain.com)$
RewriteRule (.*) http://ip/$1

what do you mean by?
  > Address should be masked as subdomain.domain.com.

I just mean i dont want the redirected address to show.

So a quick update. The redirect works, but I still see the address with the IP and not the subdomain.domain.com address.

Thanks for helping with this.

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

Do I just add this to the currently working htaccess file? Say the bottom for example?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes

this should be inside a <VirtualHost subdomain.domain.com> directive

Also, what does this mean?

> .. currently working htaccess file?
no, it must be in apache's config file, i.e. httpd.conf

> Also, what does this mean?
you need to have a virtualhost section for your subdomain.domain.com
otherwise you cannot easily redirect the urls of just that subdomain
see http://httpd.apache.org/docs/2.4/vhosts/