Add a redirect old subdomain URL to main domain using .htaccess file

I move my site to Infinity Free, use to have a blog on a sub-domain www.mysite.com/blog, want to have that redirected to my landing page www.mysite.com. Does Infinity Free allow it? If so what is the code I would use. The coding I used to do it did not work. I used:

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

Would appreciate assistance on this, Thanks

I think uour htaccess rules isn’t correct, you’d better to learn more about rewrite_mod in internet, it’s allowed to redirect users with that way.

Where did you upload this .htaccess code? I checked your account but there was no .htaccess file there.

@Admin said:
Where did you upload this .htaccess code? I checked your account but there was no .htaccess file there.

I deleted it since it did not work. I put it in the htdocs section.

@DennisM said:

@Admin said:
Where did you upload this .htaccess code? I checked your account but there was no .htaccess file there.

I deleted it since it did not work. I put it in the htdocs section.

Upon closer inspection of the code, the RewriteCond looks like it’s not going to work.

I think you can forgo mod_rewrite entirely and just put Redirect /blog http://www.mysite.com in the file instead.

I’ve tired these codes also,

RewriteRule ^blog/(.*)$ mywebsite.com steht zum Verkauf - Sedo GmbH [L,R=301]

and

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

nothing works.

I go mywebsite.com steht zum Verkauf - Sedo GmbH to redirect with

[code autolinks=”false”]
RewriteEngine On
RewriteRule ^blog/(.*)$ mywebsite.com steht zum Verkauf - Sedo GmbH [L,R=301]

But none of the blog post that under mywebsite.com steht zum Verkauf - Sedo GmbH are only the main blog page is. I need all blog post to move.

Able to work it out, had to do with the way WP posted the post. It is redirecting the main blog location just fine now. Thank you Admin for helping.

Did you try the Redirect statement I proposed? I’m happy to try and help you, but I can’t help you if you don’t follow any suggestions and just keep writing your own rules which don’t work.

@DennisM said:
I’ve tired these codes also,

RewriteRule ^blog/(.*)$ mywebsite.com steht zum Verkauf - Sedo GmbH [L,R=301]

I don’t think that RewriteRule could ever be matched. If anything, it should be ^/blog(.*)$, because a request URI always starts with a slash.

@DennisM said:

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

nothing works.

This RewriteRule is exactly the same as above, so will also never be matched. The only difference being that it only works on www.mywebsite.com and not on mywebsite.com.

Prior anything else, could you let me know what platform you are using with your site? If it’s WordPress or something else. Because I’ve been in this situation before. Probably I could dig up some notes I’ve used before to recommend you something that worked for me. Be right back