.htaccess help please

rugbyjack2005

Power Member
Joined
Oct 2, 2011
Messages
539
Reaction score
50
Hi all,

Ages ago i set up a blog on one of my sites and created a blog subdomain - blog.mysite.com. Obviously Google sees this as a separate site and i don't want it to. How do i set up a 301 redirect so that blog.mysite.com redirects to www.mysite.com/blog ?

This is where i have got so far and it doesn't work :( The first part is the redirect from non www. to www but i included it as well just encase it is messing up the other part. Help would me much appreciated as i am going round in circles at the moment!

RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite.com
RewriteRule (.*) http://www.mysite.com/$1 [R=301,L]




RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.mysite.com
RewriteRule (.*) http://www.mysite.com/blog/$1 [R=301,L]
 
Yes i've moved the blog over and that's working fine. I now want to set up a 301 redirect to pass the link juice across and to insure the links in the serps still work
 
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.mysite.com/.*
RewriteRule (.*) http://www.mysite.com/blog/$1 [R=301,L]
 
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.mysite.com/.*
RewriteRule (.*) http://www.mysite.com/blog/$1 [R=301,L]

That doesn't work either. Should i put the code in the .htaccess file that is in the site route or in the .htaccess file in the blog folder? I have tried doing it on each but it hasn't worked. The .htaccess file in the blog folder at the moment just contains the information for wordpress 5:

# 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]
</IfModule>


# END WordPress
AddType x-mapp-php5 .php
 
This should work, give it a try:

Code:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^blog.mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/blog/$1 [L,R=301]
 
This should work, give it a try:

Code:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^blog.mysite.com [NC]
RewriteRule ^(.*)$ http://www.mysite.com/blog/$1 [L,R=301]

Nope, that doesn't work either :(
 
I think the easiest way to do it would be in your cPanel -> Domains -> Redirects.
 
Couldn't you just do a simple HTML redirect on the blog.mysite.com/index.php ? That's what I do to redirect users from a Wordpress page to my forums.
 
Where i have got to so far:

Changing the .htaccess file in the site route has no effect. The .htaccess file in the blog folder seems to be the only one that changes anything.
When i change the URL in the settings section of the wordpress blog from blog.mysite.com to www.mysite.com/blog, the homepage works but none of the blog post links work. If i type in blog.mysite.com/blogpost into the browser, it will work.

Adding the redirect in the .htaccess file works for the homepage but not for the blog posts.
 
Code:
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^blog\.site\.com$ [NC] 
RewriteRule ^(.*)$ http://www.site.com/blog$1 [R=301,L]
What platform is your site?
Already been said. Do try reading.
 
Last edited:
I'll try that, thanks. How long do .htaccess files take to refresh?
 
Changes go into effect instantaneously. Feel free to add me on Skype and let me know if the change worked.

That doesn't work :( When i try to redirect it with .htaccess, it throws the wordpress blog into a bit of a wobbly and the posts stop working. I have to then delete the code, go into the settings and change the URL and change it back again to get the posts to work.

Thanks. I've added you to skype.
 
Are you changing the htaccess in the subdomain? That is where you need to set the reduction at.

Sent from my PG86100 using Tapatalk 2
 
Problem is fixed. Cause was the rewrite base and rewrite rule of WordPress were / rather than /blog/
 
Back
Top