IMB
IMB

Reputation: 15899

Redirect 301 specific pages and the rest to just one page

First I need to redirect these pages to another page in a different domain

Redirect 301 /example1 http://newdomain.com/test1
Redirect 301 /example2 http://newdomain.com/random1

Note the pages are not the same in the new domain (e.g., /example1 to /test1)

After that, I need redirect the rest of the pages to newdomain.com

E.g., Redirect 301 (everything else) to http://newdomain.com

Upvotes: 1

Views: 1176

Answers (3)

Amit Verma
Amit Verma

Reputation: 41219

If you want to use mod-alias , you can use these redirects :

RedirectMatch 301 ^/example1/?$ http://example.com/test1
RedirectMatch 301 ^/example2/?$ http://example.com/random1
#redirect everything else to the homepage of example.com
RedirectMatch ^.+$ http://example.com/

Clear your browser cache before testing these redirects.

Upvotes: 1

Abhishek Gurjar
Abhishek Gurjar

Reputation: 7476

Try below rule, using mod rewrite I am assuming you have mod rewrite enabled.

RewriteEngine On
RewriteRule ^example1$ http://newdomain.com/test1 [R=301,L]
RewriteRule ^example2$ http://newdomain.com/random1 [R=301,L]
RewriteCond %{REQUEST_URI} !^(example1|example2)
RewriteRule ^ http://newdomain.com [R=301,L]

Upvotes: 2

Dimag Kharab
Dimag Kharab

Reputation: 4519

Try this in your .htaccess

RewriteEngine On
RewriteRule ^(.*)$ http://newdomain.com/ [R=301]

Upvotes: 0

Related Questions