Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess Redirect all pages to one page

htaccess snippets to redirect all pages to one page but none of them are working for me.

I need olddomain.com , olddomain.com/pricing , olddomain.com/about , etc all to point to newdomain.com.

So olddomain.com/pricing shout not go to new domain.com/pricing.
It should just go to newdomain.com.

How can I do this?

like image 608
JediTricks007 Avatar asked Jan 28 '26 03:01

JediTricks007


2 Answers

Nothing simpler then that.

If it are different webservers, you can write this on the old ones:

RewriteEngine On 
RewriteRule ^(.*)$ http://www.newdomain.com [R=301,L]
  • ^(.*)$ means everything
  • http://www.newdomain.com is the target

If it is still the same webserver

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

It is pretty the same, but you have the condition, that the host is not newdomain.com.

like image 193
Christian Gollhardt Avatar answered Feb 02 '26 10:02

Christian Gollhardt


RedirectMatch 301 (?i)/*  http://www.yourdomain.com/WHATEVER 

or

RedirectMatch 301 (?i)/OLD/*  http://www.yourdomain.com/WHATEVER 
like image 45
MIkeH Avatar answered Feb 02 '26 09:02

MIkeH