Redirecting URL to subdomain

Hello Experts -

I have an Apache web server setup and need help with .htaccess (I think).  I can access a particular page by going to...

I want to be able to access it from...

...and I don't want the directory structure in the URL to revert back.

The subdomain blog has been created and points to the correct IP address.  How can I do this with .htaccess?

Thanks in advance.
Who is Participating?
shalomcConnect With a Mentor CTOCommented:
this is best done with a virtual host setup and not in .htaccess

however, if you have the rewrite engine working try this in .htaccess:

RewriteEngine on
RewriteCond   %{HTTP_HOST}                 ^blog\.domainname\.com$
RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
RewriteRule   ^blog\.domainname\.com(.*) /subdir/blog/$1  

chezbrgrsAuthor Commented:
This worked but I took your advice and did a  in the httpd.conf file.  Much better solution.

Thanks for your help.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.