So, I have a rails project deployed using apache server. Unfortunately, the domain name is not registered with www. So if I do https://mydoin.com
it works but https://www.mydoin.com
doesn't. Now what I need is that, if someone uses this URL with www https://www.mydoin.com
then I want to remove www from the URL. How can I do this? I am using Ubuntu 16.04 and apache 2.4.
Asked
Active
Viewed 210 times
0

Erol Aliyev
- 65
- 2
- 8

user1670773
- 967
- 4
- 12
- 23
-
You need to create an 'A' record with hostname 'www' and point it to '@' record which is already pointing to your server. – Aakash Gupta Nov 09 '17 at 22:03
2 Answers
0
First, you need to register the www.mydoin.com DNS, without this, your server will not be reached by your user. After this, you can configure a redirect in your server or rewrite your requisition, for this, follow this link: How to always remove WWW from a url with mod_rewrite?

augustocbx
- 762
- 8
- 8
0
This code will auto strip the www. for you even if its a subdomain.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
If you want to fix you DNS issue just add a 'A' record with www.yourwebsite.com

Justin
- 111
- 1
- 9