If you deploy a WordPress website on Google Cloud Hosting, you should know that AllowOverwrite is None by default, and you can’t use the .htaccess for caching and security filters.

To make WP Ghost work on the Google Cloud Platform, just follow the next steps to activate the rewrite rules:

Enable mod_rewrite in Apache

There are many ways to enable mod_rewrite if it’s not yet enabled by Google Cloud. You can find some answers here: How to enable mod_rewrite for Apache 2.2.

It’s not hard to set up Apache on Google. All you need to do is access the SSH built into your Google Cloud Platform Deployment Manager and follow the command-line actions. 

Enable mod_rewrite in Apache

Once you click on the SSH button, the Google SSH console will load. To check if mod_rewrite is enabled in Apache, run this command: 

$: a2enmod rewrite

Enable Apache AllowOverride

To enable the .htaccess rewrites, you need to edit /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
</Directory>
Enable Apache AllowOverride

Save the file changes with Ctrl + X and then press Y .

Restart Apache Service

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

sudo service apache2 restart

Now, your .htaccess should work and you can use caching and security filters and activate WP Ghost to hide the WordPress common paths.

Test New Paths & Settings

  1. Perform a Frontend Test to ensure the paths are loading correctly. Also, visit your website and check if the paths are working as intended.
  2. If everything loads fine, click the Yes, it’s working button in the WP Ghost settings.
  3. If there are any issues, click No, abort to roll back to previous settings.
Frontend test success