1. Give Yourself Permission
If you are new to google cloud then maybe you have not given permission to yourself to edit these files.
Go to Compute Engine > VM Instances >
Select the instance and click on SHOW INFO PANEL button
Now click on “Add members” button and add yourself here.
2. Enable mod_rewrite in Apache
This can be done by going through Compute Engine>VM Instances > and to the far right on the line will be SSH. Click it and select “Open in Browser window” it will take you securely inside a command line interface. Now run this command:
sudo a2enmod rewrite
3. Enable Apache AllowOverride
Use this command to modify the file:
sudonano /etc/apache2/apache2.conf
Once you’re in there, find the right spot and change it(you may find this code by moving the cursor down by 50 lines or more…)
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride ALL <—-(edit from none)
Require all granted
</Directory>
After you’ve made that change(Replace NONE with ALL), make sure to restart the server by running this command:
sudo service apache2 restart
4. Your are done now, your .htaccess file should work.
Now go for permalink changes in WordPress, it will work.