Redirect from One URL (website address) to Another | ISPserver Skip to main content

Knowledge base

Redirect from One URL (website address) to Another

Apache

The following commands may be registered in both the Web server configuration file and the .htaccess file

To redirect requests from a specific website page to the other URL, append the command to the file using:

Redirect 301 /my-old-page.html http://mydomain.com/my-new-page.html

or

Redirect permanent /my-old-page.html http://mydomain.com/my-new-page.html

 

If there are multiple pages, a new directive must be created for each one. To redirect all incoming requests to the Web server to the other URL, append the line:

 

Redirect 301 / http://mynewdomain.com/

or

Redirect permanent / http://mynewdomain.com/

Restart the Apache Web server using the command:

apachectl restart

or

apache2ctl restart

Nginx

In the Web server configuration file, create the following section:

server {
  listen 80;
  server_name my-old-website.com;
  return 301 $scheme://my-new-website.com$request_uri;
}

When requesting the Web server, the redirect will transfer to the my-new-website.com address using my-old-website.com address

Restart the Nginx Web server using the command:

systemctl restart nginx
Return to category