A
A
a16a2018-03-15 10:47:42
htaccess
a16a, 2018-03-15 10:47:42

How to make a redirect without www for a subdomain?

Good afternoon.
Faced a problem. There is a subdomain "sub.site.com" and you need to redirect from "www.sub.site.com" to "sub.site.com".
Googled and the solution suggested didn't work for me. If someone has solved this problem, please share your answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kosarinin, 2018-03-15
@a16a

In .htaccess

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

Don't forget to enable mod_rewrite
a2enmod rewrite
service apache2 restart

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question