Angelin Calu
Angelin Calu

Reputation: 1915

.htaccess issue when trying to remove the www from subdomain

What I am trying to do is redirect every single page to one subdomain page using .htaccess.

I am doing that with the following code:

RewriteEngine On
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} ^(www\.)?calu\.info$ [NC]
RewriteRule ^ http://angelin.calu.info/ [R=301,L]

And everything works fine, except for the thing that this subdomain accepts also www.angelin.calu.info which is wrong.

I need to redirect everything from www.angelin.calu.info to http://angelin.calu.info. I have done several tries with no luck whatsoever. The result in all of my tries was:

http://angelin.calu.infoangelin/

What am I doing wrong?

Upvotes: 0

Views: 76

Answers (1)

Sumurai8
Sumurai8

Reputation: 20737

You are forgetting to keep the request uri. Use the following code (copied from somewhere; don't have the original source to give credit):

<IfModule mod_rewrite.c>
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

Edit:

I suppose you have something like the following code in your .htaccess

RewriteCond %{HTTP_HOST} ^(.*)\.calu\.info$
RewriteRule ^(.*)$ http://%{HTTP_HOST}%1/$1

This needs to be removed

Upvotes: 1

Related Questions