Code to redirect all visitors of website to another website without wordpress pulgin
Code to redirect all visitors of website to another website without any wordpress pulgin.
Suppose the followings;
old website: abc1.com
New website: abc2.com
Methods to to redirect
- Redirect with .htaccess (for Apache servers):
- Redirect with Nginx configuration (for Nginx servers):
1. Redirect with .htaccess (for Apache servers):
1 2 3 | RewriteEngine On RewriteCond %{HTTP_HOST} ^website1\.com$ [ NC] RewriteRule ^(.*)$ http://website2.com/$1 [L,R=301] |
2. Redirect with Nginx configuration (for Nginx servers):
You can redirection directly in your server block configuration.
1 2 3 4 5 | server { listen 80; server_name website1.com; return 301 http://website2.com$request_uri; } |