Redirect domain to new domain using htaccess - .htaccess

I've looked around and around and couldn't find anything that worked specific to my needs.
I need to figure out how to mass redirect all URLs with the old domain to the new domain. For example:
http://www.olddomain.com/blog-post-title
to
http://www.newdomain.com/blog-post-title
The URI is always the same I just need the htaccess to recognize when a URL has this and redirect it to the new domain.
Any ideas?
Thank you!

If you want to redirect your old domain wholesale to the new one, you can just use the Redirect directive
Redirect / http://www.newdomain.com/

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

Need help redirecting one website URL to another with apache2 and .htaccess

I have two domains - https://hosting.opensimcity.org, and http://paradigm.pocketmud.com and I want to redirect the latter to the former. That is, when someone connects to http://paradigm.pocketmud.com I want it to redirect to https://hosting.opensimcity.org/paradigm
Any tips on doing this in my .htaccess file?
Just try the following htaccess redirect code:
Redirect 301 / https://hosting.opensimcity.org/paradigm
This 301 redirect response notifies the search engines that the page has moved permanently from the old URL to the new URL. The search engines also transfer the old URL page rank to the new URL.

Using htaccess to redirect URL from one query string to another

I need to redirect
from
/showthread.php?tid=6
to
/viewtopic.php?t=6
using htaccess. We moved from MyBB to PhpBB and would like to safe links leading to our site.
The domain remains the same. All my attempts failed.
Can someone help?
^showthread.php?tid=(\d+)$ viewtopic.php?t=$1
This should do the trick with htaccess redirect parameter :)

Redirect domain to subfolder with some specific pages fallback

I need to change website domain from www.domain.com to www.newdomain.com/en but I also need to specify some pages from old website to new website like www.domain.com/page to www.newdomain.com/en/subfolder/subfolder/page.
Last thing should be great keeping one subfolder path of old website free of redirect like www.domain.com/admin in order to keep backend access to old website.
What would you suggest me to add to old site htaccess file in order to achieve that with a sort of fallback mechanism for specifc pages and whole domain to subdirectory?
Thank you
You can add the following 301 redirect to your oldsite/htaccess :
Redirect 301 / http://newdomain.com/en/subfolder/subfolder/
This will redirect all requests from your old site to the subfolder in your new site
Edit : as per your comment,
to exclude a specific path from the redirection, you may use RedirectMatch
RedirectMatch 301 ^/((?!page1|page2).*) http://newdomain.com/en/subfolder/subfolder/$1
This will not redirect /page1 or /page2 .

.htaccess 301 redirecting folder to absolute url?

Hey I'm just setting up a few 301 redirects but I can't work out how to do this particular function.
I have a ton of pages on my existing site e.g.
/products/23
/products/3
/products/57
/products/36
..etc
That I all want to point to one page on a new domain .e.g.
http://www.mynewdomain.com/store
I've tried a few RewriteRules with no success!
Thanks for any help !
It should work with a RedirectMatch directive (although you don't specify in your question how to pass the product codes to the new page):
RedirectMatch301 ^/products/(.*) http://www.mynewdomain.com/store/$1
This rule will redirect /products/NNN to http://www.mynewdomain.com/store/NNN (with HTTP status code 301).

Resources