Redirect Sub-Domain to Directory

jlpeifer

Verified User
Joined
Jun 6, 2006
Messages
97
I feel like I'm caught in an .htaccess Catch 22 nightmare. Help?

I have a hosting customer who had a simple HTML site (www.villepaintersinc.com) who decided they wanted a blog. Since their existing site was static and because they didn't want to spend the money on converting to a full content management system I created a subdomain called "blog", installed Wordpress on it, and allowed them to blog away at "blog.villepaintersinc.com".

Yesterday a local design company replaced the simple HTML content with new-improved design. The removed the "blog" subdomain via the DA CP, but left "blog" subdirectory structure and all of its data untouched.

Then, through some devilry that's over my head, they somehow set things up so that anyone going to "www.villepaintersinc.com/blog" would see the content that was previously available at "blog.villepaintersinc.com".

Since the subdomain "blog" had been removed from the DA CP there was no longer a DNS entry for "blog.villepaintersinc.com". So when people visit "blog.villepaintersinc.com" they receive a "server not found" error.

Now the client is asking, "Hey... when people type in 'blog.villepaintersinc.com' can you just redirect them to 'www.villepaintersinc.com'?"

I've hacked around with htaccess files, custom HTTPD configs, and DNS entries until my head is spinning.

Can anyone help me through this puzzle?
 
Hello,

To setup apache, go to:

Admin Level -> Custom Httpd configurations -> villepaintersinc.com

In the top text area, add this *one* line:

Code:
ServerAlias blog.|DOMAIN|


then click "Save". Since that 'blog.villepaintersinc.com' will become an alias for 'www.villepaintersinc.com'. And of course make sure to create A-type record for 'blog.villepaintersinc.com' in DNS manager.

That's up to you with mod_rewrite to redirect to 'www.villepaintersinc.com'.
 
Thanks zEItEr!!!

This is definitely a step in the right direction. I followed your instructions. Now when I go to "blog.villepaintersinc.com" I am redirected to "http://www.villepaintersinc.com/blog/http:/www.villepaintersinc.com/". While this isn't ideal, it at least redirects me to a custom 404 page not found with where viewers at least get to see the new site's normal header/banner info.

Is it possible that the malformed URL is the result of .htaccess shenanigans that the customer is trying to pull off?
 
Just a quick follow-up... Yes, it was in fact the .htaccess file that was creating the weird URL noted in the previous post.

Thanks again to zEItEr for the recommended fix!
 
Back
Top