Redirect sub domain and all its files old or new to new url - .htaccess

I have been searching for this, not sure if it can be done.
I want to redirect a subdomain and all its files old or new to the root domian
I did a basic redirect and the subdomain redirects to the domain just fine.
Problems is if a specific file is added to the subdomain ie. http://sub.maindomain. com/help.htm is brings up a 404 Page not found
Thanks for your help.
Dave

Related

Redirect Whole website to new domain with .htaccess file

Can Anyone help me to find the solution how to redirect my whole old url to new url.
For example
My old ulr is:
www.example.com.au/blog
I want to redirect this domain to new domain like that
www.newdomain.com.au/blog
Try
Redirect 301 / www.newdomain.com.au/blog
More infos here

How to redirect only existing pages of a website to the new domain but exclude some specific folders?

I wish to setup redirects in the .htaccess file of the old domain so that only working pages get redirected to the new domain. Any links to the non-existing pages of the old domain should display 404 error. So, for example
OLD Domain: https://www.oldurl.com
NEW Domain: https://www.newurl.com
I want the following redirects to work
https://www.oldurl.com => https://www.newurl.com
https://www.oldurl.com/some-page.php => https://www.newurl.com/some-page.php
https://www.oldurl.com/folder/some-page.php => https://www.newurl.com/folder/some-page.php
But I do not want the following redirects to point to the new site. They should display 404 error.
https://www.oldurl.com/bad-folder
https://www.oldurl.com/bad-link.php
https://www.oldurl.com/non-existing-page.html
etc.
So, in short, any valid page that already exists on the old website should be redirected to new website except for some specific folders and non-existing links (they should point to 404 error page on old website)
Thanks in advance!

htaccess redirect specific pages to another domain

I’m having some real problems with 301 redirects in my .htaccess file.
I have about 20 pages on an old site that I need to redirect to pages on a new site. The URL structure of the new site is totally different.
Here’s one that I tried:
Redirect 301 /dan-carr-gear-list/travel-gear https://dancarrphotography.com/gear/travel/
Unfortunately, this doesn’t work.
What happens is that you get redirected to https://dancarrphotography.com/gear/travel-gear/ for some reason.
I just can’t figure it out.

Moving VERY old website to New Domain

I have been creating a new website for a company and would like some advice on writing a rewrite file.
I obviously would like to keep our current rankings and transfer them to the new site and i am just wanting to make sure I am doing it correctly.
Would a standard 301 redirect with old links to new links work if I also write a rewrite to the home page?
This isn't my area and any help would be great.
Justine
This Redirect htaccess code below in an htaccess file in the old site's folder would redirect all old site pages and posts to identical matching pages and posts with the same identical structure on the new site/domain.
RedirectMatch 301 ^/$ http://www.newdomain.com/$1
For some web hosts you need to include the folder name where the website is physically installed. olddomain.com would be the name of the folder and not the URL|URI name.
RedirectMatch 301 ^/olddomain.com$ http://www.newdomain.com/$1

.htaccess redirect questions

I'm redirecting my website from my old domain to my new one.
Preety much everything is done, I have only 2 questions:
1) The website is a bit different on the new domain (I removed some pages and sections). Is it ok (SEO-wise) to redirect the pages I have on the old domain to the same pages on the new domain and then redirect every other page to the root of the new domain?
So basically, redirect old pages that don't exist anymore to the root of the new domain.
2) How do I do that?
For now I have a bunch of rules like:
Redirect 301 /oldfile.html http://www.newdomain.com/newfile.html
How do I add a rule to say redirect tha pages as instructed above AND redirect every other page to the root of the new domain?
Thank you for your time!
1) Yes, it's good.
2) You can't, you'll have to select the folder root you want to redirect to your domain root for bulk redirect if you want to be sure of what you do.
RewriteRule ^folder/(.*)$ domain.xxx [R=301,L]

Resources