htaccess redirect issue in godaddy - .htaccess

I have a htaccess which will redirect all subdomain to parent domain except one domain.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]+)\.theonlytutorials\.com$ [NC]
RewriteCond %1 !^(blog|www)$ [NC]
RewriteRule ^(.*)$ http://theonlytutorials.com/$1 [L,R=301]
This code was working fine in my previous hosting. But in Godaddy it doesn't seems to be working.
It is redirecting, but to the exact hosting location.
One of my URL structure:
www.theonlytutorials.com/video/58/4496/ChessBaseGmbH
Instead it is redirecting to:
www.theonlytutorials.com/others/tutorials/video/58/4496/ChessBaseGmbH
Where others / tutorials are the folders created in my hosting

On Go Daddy (and probably some other Hosts) the site folder names should be included in your redirect code.
RedirectMatch 301 ^/site-folder-name/video/58/4496/ChessBaseGmbH/$ http://the full URL here where you want the redirect point to
If you wanted to redirect a link from the /blog/ folder / site to another site
RedirectMatch 301 ^/blog/video/58/4496/ChessBaseGmbH/$ http://the full URL here where you want the redirect point to
Let's say you want to do a redirect from a site that is in this folder /others/ and you want to redirect to your root domain.
RedirectMatch 301 ^/others/video/58/4496/ChessBaseGmbH/$ http://the full URL here to your root domain where you want the redirect to point to
And logically the same thing would probably be true if you have this folder structure /others/another-nested-folder/
RedirectMatch 301 ^/others/another-nested-folder/video/58/4496/ChessBaseGmbH/$ http://the full URL here to your root domain where you want the redirect to point to

Related

.htaccess redirect for https://.co.nz website to .com version(including all subpages)

I am palling to migrate my website from the .co.nz to the .com but need to setup a 301 redirect so all of the individual pages will still be routed properly without any 404 pages from .co.nz version
All https://
I want "https://www.example.co.nz/" to go to "https://www.example.com"
Which will also redirect
https://www.example.co.nz/contact to go to https://www.example.com/contact
https://www.example.co.nz/men to go to https://www.example.com/men
Many Thanks
This should do the trick:
Redirect 301 / https://www.new-example.com/
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !new-example.com$ [NC]
RewriteRule ^(.*)$ https://new-example.com/$1 [L,R=301]
You put this in the .htaccess file of the .co.nz domain. This will redirect all your content and subfolders to their appropriate subfolders on the new domain (so example.me/subfolder to example.com/subfolder) AND also force redirect to https part.

Redirect Website Homepage Only

I have two different websites that are hosted on different servers. I would like to redirect the homepage of the old site (www.oldsite.com.au) to the homepage of the new site (newsite.com.au). However, I do not want any pages within the old site (www.oldsite.com.au/page) to redirect to the new one (newsite.com.au/page). So, www.oldsite.com.au must redirect to newsite.com.au, but any other pages or files within the old site must not redirect.
All the .htaccess ideas I've tried just redirect every file from the old site to the new one.
Try one of these:
RedirectMatch 301 ^/$ http://newsite.com.au/
or
RewriteEngine On
RewriteRule ^$ http://newsite.com.au/ [L,R=301]
If you don't want a 301 (permanent) redirect, remove the 301 from the RedirectMatch or the =301 from the square brackets in the rule's flags.

301 Redirect in .htaccess

I need to redirect my website to a new domain name but I want it to also redirect all of the pages. I want www.myoldsite.com/ to redirect to www.mynewsite.com/ but I also want all of the pages to redirect.
For example: www.myoldsite.com/faq to redirect to www.mynewsite.com/faq and so forth and so on. I know how to do it by doing each individual page but I have a lot of pages. How do I rewrite the 301 for it to basically change the root domain name but keep the directories and pages the same? Thanks a million!
You just need this in the htaccess file in your old domain's document root:
Redirect 301 / http://www.mynewsite.com/
If both your old site and new site share the same document root, then you need mod_rewrite instead:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?myoldsite\.com$ [NC]
RewriteRule ^(.*)$ http://www.mynewsite.com/$1 [L,R=301]

Htaccess 301 redirect index.html also redirecting addon domain issue

I have this issue that I can't figure out how to fix:
I am trying to redirect an html site to a wordpress site.
The domain I am trying to redirect as a primary domain which has an HTML site on it obviously with an index.html as the main page.
Now - there are 2 more sites on the same host which use addon domains and sitting in 2 directories:
example.com and example2.com (they are both wordpress sites)
I created an htaccess file, pretty simple and put many lines of redirecting html pages of the primary domain to another domain like so:
Redirect 301 /somepage.html http://www.newdomain.com
Redirect 301 /anotherpage.html http://www.newdomain.com
etc, etc..
at this point all the .html pages were redirecting fine.
Now - the issue is:
I also wanted to point the main page (index.html) to another domain (ww.newdomain.com) so I put this line too (same as I did for other html pages):
Redirect 301 /index.html http://www.newdomain.com
it seemed fine to me but what happened was that it redirects the index.html to the new domain but also redirected the 2 wordpress sites which are sitting in a different directory that I mentioned earlier...
I dont knw why did it happen but I can assum that redirecting the first page that the browser meet redirecting everything on the main root including addon domains.
does anyone have a solution to that?
Thanks
Try changing (which I think you have a typo, I'm guessing it's not the same as the 2nd redirect in the first part):
Redirect 301 / http://www.newdomain.com
to:
RedirectMatch 301 ^/$ http://www.newdomain.com
EDIT: Since there appears to be more than one domain with the same document root try:
RewriteEngine On
# for redirecting "/"
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain.com
RewirteRule ^$ http://www.newdomain.com/ [R=301,L]
# for redirecting "/somepage.html"
RewriteCond %{HTTP_HOST} ^(www\.)?olddomain2.com
RewriteRule ^somapage.html$ http://www.newdomain2.com/ [R=301,L]
etc.

Problems with htaccess Redirect (Page on one domain to same page on another)

I'm trying to redirect a few pages to a new domain and I have done this before but for some reason I can't get the code to work.
RewriteEngine On
Redirect 301 http://domain.com/page1.html http://domain2.com/page1.html
Can anyone see where I'm going wrong?
In .htaccess file the below code will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain.
The .htaccess file needs to be placed in the root directory of your old website
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Since you say you only want to direct a FEW of your pages and not all of them, you can do:
RewriteEngine On
Redirect /~myaccount/oldpage.html http://www.newsite.com/newpage.html
You specify the path to the page on your current server followed by the URL to redirect to.
OR you can do:
RedirectMatch 301 ^/oldpage\.html$ http://www.newsite.com/newpage.html

Resources