1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.htaccess help please

Discussion in 'Black Hat SEO' started by rugbyjack2005, Jun 15, 2012.

  1. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    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]
     
  2. moonlighsunligh

    moonlighsunligh Jr. VIP Jr. VIP Premium Member

    Joined:
    May 1, 2010
    Messages:
    1,623
    Likes Received:
    218
    You should install your blog in the folder called blog, not on a subdomain.
     
  3. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    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
     
  4. moonlighsunligh

    moonlighsunligh Jr. VIP Jr. VIP Premium Member

    Joined:
    May 1, 2010
    Messages:
    1,623
    Likes Received:
    218
    Try this:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^blog.mysite.com/.*
    RewriteRule (.*) http://www.mysite.com/blog/$1 [R=301,L]
     
  5. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    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
     
  6. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    Anyone?
     
  7. Aty

    Aty Jr. VIP Jr. VIP

    Joined:
    Jan 27, 2011
    Messages:
    5,396
    Likes Received:
    3,690
    Home Page:
    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]
    
     
  8. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    Nope, that doesn't work either :(
     
  9. lovetospooge

    lovetospooge Junior Member

    Joined:
    Jul 24, 2011
    Messages:
    171
    Likes Received:
    91
    Location:
    Cape Town, ZA
    I think the easiest way to do it would be in your cPanel -> Domains -> Redirects.
     
  10. buchner

    buchner Junior Member

    Joined:
    Feb 21, 2010
    Messages:
    152
    Likes Received:
    59
    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.
     
  11. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    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.
     
  12. Aty

    Aty Jr. VIP Jr. VIP

    Joined:
    Jan 27, 2011
    Messages:
    5,396
    Likes Received:
    3,690
    Home Page:
  13. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    Code:
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^blog\.site\.com$ [NC] 
    RewriteRule ^(.*)$ http://www.site.com/blog$1 [R=301,L]
    Already been said. Do try reading.
     
    Last edited: Jun 15, 2012
  14. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    I'll try that, thanks. How long do .htaccess files take to refresh?
     
  15. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    Changes go into effect instantaneously. Feel free to add me on Skype and let me know if the change worked.
     
    • Thanks Thanks x 1
  16. rugbyjack2005

    rugbyjack2005 Power Member

    Joined:
    Oct 2, 2011
    Messages:
    539
    Likes Received:
    50
    Location:
    United Kingdom
    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.
     
  17. 67731

    67731 Regular Member

    Joined:
    Aug 27, 2011
    Messages:
    231
    Likes Received:
    47
    Occupation:
    SEO TECH - Looking to work for myself. . .
    Location:
    Las Vegas NV
    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
     
  18. artizhay

    artizhay BANNED BANNED

    Joined:
    Nov 21, 2010
    Messages:
    1,867
    Likes Received:
    1,335
    Problem is fixed. Cause was the rewrite base and rewrite rule of WordPress were / rather than /blog/