+3 votes
in Web & Google by (15.7k points)
edited by
I installed the blog (wordpress) of my website in a folder, but now I want blog to open as a subdomain. I created subdomain and using cpanel, added redirection from directory to subdomain. But, it did not work as now I am able to access my blog from both subdomain and directory. What is the correct syntax to add redirection via htaccess?

1 Answer

+1 vote
by (18.6k points)
edited by

I think cpanel doesn't add redirectmatch as I had the similar issue in past. You need to modify your .htaccess file manually. To redirect from directory to subdomain, make the following changes in your .htaccess file present in public_html folder.

RewriteEngine On
RedirectMatch 301 ^/blog/(.*)$ http:/ /blog.example.com/$1