Skip links

WordPress 404 error in google cloud instance

Enable mod_rewrite in Apache

There are a number of ways to enable mod_rewrite, in case it’s not yet enabled on your setup. See this Stack Overflow thread for various ways this may be done on different setups: How to enable mod_rewrite for Apache 2.2.

If you are still with me on this journey, the next one is going to be the least familiar and most technical of the steps. Don’t be intimidated but you’re going to need to roll up your sleeves and get into the command line via the browser based SSH built into your Google Cloud Platform Instance.
You’ll get to the browser based ssh 

Step 1) Make sure you have enabled mod_rewrite in apache. This can be done by going through Compute Engine>VM Instances > identify the correct instance and to the far right on the line will be SSH. Click it and it will take you securely inside a command line interface. Run this command:

$: a2enmod rewrite

Enable Apache AllowOverride

2) Check your virtualhost configuration in /etc/apache2/apache2.conf and make sure that it is configured with AllowOverride All instead of the default AllowOverride None for your web root directory. This tells apache it is ok for settings in .htaccess files to override settings. Use this command to modify the file.

sudo nano /etc/apache2/apache2.conf
Once you're in there, find the right spot and change it.

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride ALL <----(edit from none)
        Require all granted

After you’ve made that change, make sure to restart the server:

sudo service apache2 restart

Now, your .htaccessshould work. You can also make this change inside a virtual host, which would normally be preferable, but that depends on the way Apache is set up.

Do NOT follow this link or you will be banned from the site!

Are you interested in our products?

Enter your email address and click submit. You'll be added in our mailing list to receive the following things,
  • Our Scripts & Themes Updates
  • Offers & Coupon code
  • Weekly Newsletter
Holler Box