Webfaction Subdomain Forwarding

I have shared hosting on webfaction and I want www.mydomain.com to go to mydomain.com, just like www.stackoverflow.com redirects to stackoverflow.com. In the webfaction dashboard, I set up a CNAME record linking the subdomain www.mydomain.com with mydomain.com, but this does not seem to work. Maybe this means that mydomain.com is a virtual host and does not have an A record on the IP address?

In any case, can someone help me figure out the right way to do this, either in the webfaction control panel or directly in the httpd.conf file? Thanks in advance.

+6
dns cname webfaction
source share
1 answer

The solution I use is to create a Static / CGI / PHP application (which I call redirects) and put the .htaccess file in its root. I specify all the domains and subdomains that need to be redirected to this application, and then I fill out the .htaccess file with all the necessary redirection directives for my server, for example:

RewriteEngine on RewriteCond %{HTTP_HOST} www.example.com RewriteRule ^(.*) http://example.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} www.example1.com RewriteRule ^(.*) http://example1.com/$1 [R=301,L] 

It works well, and since it is instantaneous, it is easy to debug.

+8
source share

All Articles