Mobile app version of vmapp.org
Login or Join
Berryessa370

: How to redirect and keep the previous URL with .htaccess? I have created a subdomain and want to redirect it to a URL. But I want to keep the subdomain as the URL of the redirection. I

@Berryessa370

Posted in: #Domains #Htaccess #Redirects #Subdomain

I have created a subdomain and want to redirect it to a URL. But I want to keep the subdomain as the URL of the redirection. I have searched for it but none of them worked for me!

Subdomain: sub.domain.com
New URL: 10.10.10.10:8080


.htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub.domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.sub.domain.com$
RewriteRule ^/?$ "http://10.10.10.10:8080" [R=301,L]

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Berryessa370

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ann8826881

You have a few fundamental problems with your last line.

RewriteRule ^/?$ "http://10.10.10.10:8080" [R=301,L]


Change it to:

RewriteRule .* 10.10.10.10:8080 [R=301,L]


Of course, I assume that the IP address 10.10.10.10 in your example is just an example and that you are not trying to redirect to a private IP address that is not routable. As well, port 8080 is not an HTTP protocol and that you do have a web server answering that port.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme