I have a main site hosted on Heroku and a WordPress blog hosted on Bluehost. To get to the blog, a user types in blog.example.com and it works. However, how would I redirect the URL so that when the user types in blog.example.com the URL changes to example.com/blog?

I added these two commands into the .htaccess file and the site goes into a redirect loop:

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

This is what I have in the .htaccess file so far (WordPress default):

     RewriteEngine on
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress


Read more here: How to redirect a subdomain to a website directory


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , ,

Wordpress related questions and answers: