A
A
Aidar2016-12-13 15:55:53
Apache HTTP Server
Aidar, 2016-12-13 15:55:53

How to redirect a subdomain from www?

Hello! How to make a redirect from www.subdomain.domain.ru to subdomain.domain.ru ?
Is it possible to do this at all? It's just that if you enter subdomain.domain.ru, then everything is fine, but if www.subdomain.domain.ru, then it says "Server not found"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Алексей, 2016-12-13
@alsopub

First of all, you need www.subdomain.domain.ru to have an ip address (for it to work ping www.subdomain.domain.ru).
That is, you need to resolve the issue with DNS - either add an A record with the IP address of your server, or www.subdomain.domain.ru CNAME subdomain.domain.ru
Further in the config where ServerName subdomain.domain.ru you can add ServerAlias ​​www.subdomain. domain.ru
Then decide - either leave it or add the Rewrite rule.

A
Azazel PW, 2016-12-14
@azazelpw

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question