0

How can I make all requests to pages at http://a.com go to the same page but on http://b.com?

htaccess currently looks like this...

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
  • Please clarify your specific problem or add additional details to highlight exactly what you need. Are you using apache or nginx? What have you tried... – Tunji Dec 30 '16 at 4:44
  • There are lots of plugin to update url. With the help of those plugin you can change url from all pages in just one click. For example: If your url is like this http://a.com/page1. Then you need to replace only http://a.com part (not page name), then replace only this part with the help of any update url plugin. And you can also again change it back any time. You can do this without plugin also by using update query for wp_posts table in phpmyadmin. – Rishabh Dec 30 '16 at 6:03
1

Assuming you are using apache and have access to edit code files, add the following into your .htaccess file in the root directory of your site, somewhere right after the "RewriteEngine On" line.

RewriteCond %{HTTP_HOST} ^a.com [NC]
RewriteRule ^(.*)$ http://b.com/$1 [L,R=301,NC]
  • I've added some text to the question. Do I need an additional rule for the domain with www prefixed? – Ian Warburton Dec 30 '16 at 21:45
  • 1
    Yes, you can copy and paste the two lines for any other redirections, but there is also an "[OR]" keyword that can be used to match multiple RewriteCond's to the same RewriteRule. – Michael Waskosky Jan 2 '17 at 7:48
  • Cool, it works. – Ian Warburton Jan 8 '17 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.