Permalinks in Wordpress not working on Google Cloud Platform

5,854

use ssh: edit your apache .conf

sudo nano /etc/apache2/apache2.conf

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

...and then restart apache2 using:

sudo service apache2 restart

Share:
5,854

Related videos on Youtube

alexforyou
Author by

alexforyou

Updated on September 18, 2022

Comments

  • alexforyou
    alexforyou over 1 year

    I’ve been beating my head against the wall for three weeks trying to get permalink settings in Wordpress to work on Google Cloud Platform. Here’s a quick summary of what I have, what I’m trying to do, and what I’ve already tried.

    I have two servers on GCP that are both experiencing the same problem.

    Server 1 (Migrated Server) This server has four Wordpress sites that I migrated from a shared hosting provider. All four of these WordPress sites have issues unless I use the first setting in the Permalinks section under Settings for WordPress. OS: Debian 8 Website: www.example.com

    Server 2 (Google Deployed) This server is a single Wordpress deployment that was launched using Google’s pre-built wordpress instance deployment. OS: Debian 8 Wordpress: 4.8

    The Permalinks Problem: In Wordpress -> Settings -> Permalinks -> If I chose “Plain - http://example.com/?p=123” I can load the front page of the site and navigate to any sub pages. If I choose anything OTHER than “Plain”, whether that’s “Day and name”, “Month and name”, “Numeric”, “Post name”, or “Custom Structure”, then I can only load the front page of the site and I’m unable to load any of the other pages. When I try to load any of the other pages I receive the following error:

    Not Found The requested URL /loopstats/ was not found on this server. Apache/2.4.10 (Debian) Server at example.com Port 80

    Now he’s the real kicker, Server 2 (GCP Deployed), which I used the Google Deployment Manager to launch the Wordpress instance, the default setting for Permalinks is the “Custom” option with the following slug:

    /index.php/%year%/%monthnum%/%day%/%postname%/
    

    Again, if I use ANY other setting other than this custom link, I can only load the front page and ALL other links are broken.

    When I go back to Server 1 (Migrated Server), and I input this slug in the custom field, then everything works on the Server 1. This doesn’t work for me though as I’m now left with these incredibly nasty links that contain index.php. (I’m told this is terrible for SEO purposes).

    Things I’ve tried:

    1. Days of googling. I have questions on Wordpress’s main site, some plugin sites, Reddit, and I keep coming up blank.

    2. Apache2 Rewrite: From different sites I’ve read online, I’ve found that Apache Rewrite can be the issue here if it’s not enabled. I went through and made sure this was enabled on both sites.

    3. .htaccess file: I’ve nuked the .htaccess file on Server 1 and replaced it with the .htaccess file from Server 2 (Google Deployed). This didn’t yield any benefits to the permalink structure other than allowing me to now use the Custom slug from Server 2. (/index.php/%year%/%monthnum%/%day%/%postname%/)

    This is the content of my current .htaccess file on both servers:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule># END WordPress
    # END Wordpress
    

    Does anyone have any idea what I’m doing wrong? I want to be able to use better permalinks and get rid of these hugely nasty links.