RewriteRule in htaccess change url without content

I have one site with wordpress that have blog page.

So now for this page Url is somthing like http://abc.com/blog.

Read More

But i want to convert this url to http://blog.abc.com

I added code in .htaccess file but rewrite is not working. Rewrite mode is also on in apache.

Any one have idea how t o change this url ?

I want to test in my local wamp first, so please give suggestion with localhost too, if possible.

Code is that i tried

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^abc.com/blog [NC] 
RewriteRule http://blog.abc [R=301,L]

Related posts

Leave a Reply

1 comment

  1. Your rule needs to look something like:

    RewriteCond %{HTTP_HOST} ^abc.com$ [NC] 
    RewriteRule ^blog/(.*)$ http://blog.abc.com/$1 [R=301,L]
    

    the %{HTTP_HOST} variable is only the hostname, and no path information is part of it (e.g. /blog). The RewriteRule takes at least 2 parameters:

    RewriteRule <pattern to match against the URI> <if matched, rewrite/redirect to this URL> <flags>