0

Is there a way in Rails to re-route all subdomains to www? For example, if someone enters https://blah.example.com/campaign/39/public it would route to https://www.example.com/campaign/39/public

blah can be changed to anything like https://google.example.com/campaign/41/public but it would always route to www https://www.example.com/campaign/41/public

Abhishek T.
  • 1,133
  • 1
  • 17
  • 33
user2974739
  • 619
  • 1
  • 7
  • 20

1 Answers1

0

Yes, it is possible to redirect any domain link to www.

You need to change your conf file as below For Apache2 and httpd

<VirtualHost *:80>
    ServerName blah.example.com
    Redirect permanent / http://www.example.com/
</VirtualHost> 

And if you use nginx than use this

server {
    listen       80;
    server_name  example.com;
    return       301 http://www.example.com$request_uri;
}

server {
    listen       80;
    server_name  www.example.com;
    ...
}

Hope it will help you..

Hardik Upadhyay
  • 2,639
  • 1
  • 19
  • 34