+3 votes
in Web & Google by (56.8k 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

+2 votes
by (71.8k points)
selected by
 
Best answer

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


...