Configure 301 Redirects for Websites on Google Cloud (Apache)
If you want to redirect webpages on your website to a new (permanent) URL, your best option is to configure a 301 redirect.
In this tutorial you will learn how to properly configure 301 redirects for websites running on Google Cloud Platform.
Before starting this tutorial, you should have already deployed a website on Google Cloud Platform.
There are 4 steps in this tutorial:
1. Connect to VM Instance



2. Open Apache Config File
In this example I am going to redirect eborchids.com/post1 to eborchids.com/post2.

For most web projects, run the following command:
sudo nano /etc/apache2/apache2.conf
For Bitnami web projects, run the following command:
sudo nano /opt/bitnami/apps/wordpress/conf/httpd-app.conf
3. Edit Apache Config File

To redirect eborchids.com/post1 to eborchids.com/post2
Redirect 301 /post1 https://eborchids.com/post2
4. Restart Apache
For changes to take effect, restart your Apache server.
For most web projects, run the following command:
sudo service apache2 graceful
For Bitnami web projects, run the following command:
sudo /opt/bitnami/ctlscript.sh restart apache
Did it Work?
Make sure to test your 301 redirect to ensure that they’re configured properly.
If you have any questions or comments, please post them below!
Up Next…

