(solved) removing www from subdomain


#1

Hello,

Just to let you know how to get this working on dreamhost since subdomains have automatically placed www in front of the subdomein.

For example

Domain is : www.example.com
Created subdomain is : sub.example.com

In the browser it says : www.sub.example.com

You can not remove it in your configuration so you need to have to create a .htaccess file with THIS code in it. A lot of .htaccess example simply do not work on dreamhost for some reason.

Steps :

  • Create a .htaccess file
  • Fill in the following information :

Options +FollowSymLinks

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.sub.example.com
RewriteRule ^(.)$ http://sub.example.com/$1 [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .
- [L]

  • Save it
  • Upload into your ROOT AND !! SUB DOMAIN folder

Clear your browser and there it goes.

This has given me headaches but apparently this one actually works on dreamhost.

Have fun.


#2

There’s a much easier fix.

Go into the DreamHost Panel, under “Manage Domains”, and edit the subdomain. There’s an option on there to automatically add/remove www, which works just as well for subdomains as for “main” domains.