La Page PT
La Page PT

Reputation: 621

How to redirect a subdomain to an ip an keep the subdomain in the address bar?

On my domain lapagept.com, I have create a subdomain sm.lapagept.com.

When a user enters http://sm.lapagept.com in his browser's address bar, he is redirected to http://173.209.38.131/~sm. The new address in the address bar is changed for http://173.209.38.131/~sm.

Here is the code we use in the .htaccess file on lapagept.com to make this :

RewriteEngine on

RewriteCond %{HTTP_HOST} ^sm\.lapagept\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sm\.lapagept\.com$
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "http\:\/\/173\.209\.38\.131\/\~sm" [R=301,L]

My question :

When a user enters http://sm.lapagept.com in his browser's address bar, would it be possible to get redirected to http://173.209.38.131/~sm but to keep http://sm.lapagept.com in his address bar?

Upvotes: 0

Views: 245

Answers (1)

Aurélien Gasser
Aurélien Gasser

Reputation: 3120

It's not possible, for security reasons.

There are ways to update the URL in the client's browser address bar without reloading the page, but it doesn't apply to your case because you're trying to change the domain part of the URL.

I would recommend

  1. setting up your DNS provider to direct requests to sm.lapagept.com to 173.209.38.131
  2. setting up your web server at 173.209.38.131 to accept and server requests for the domain sm.lapagept.com. If you're using apache, this can be done by using the ServerName, ServerAlias properties in your VirtualHost settings.

Upvotes: 1

Related Questions