skip to Main Content

I’m attempting to clean some urls in a simple PHP application I have deployed on google cloud servers (Ubuntu). However, the redirect conditions I have written in a .htaccess file seemed to be ignored. I’ve went through Google’s documentation and I haven’t found a solution, I’ve gone through my .config files and ensured that mods_rewrite was enabled. I was thinking that because i’m on a shared server that the rules are being ignored. IF anyone has any suggestions or workarounds, please suggest.

Here is the .htaccess file for reference:

Options +MultiViews

#Remove php extension
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule ^(.*)$ $1.php

#Remove html extension

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME}.html -f
    RewriteRule ^(.*)$ $1.html

2

Answers


  1. Chosen as BEST ANSWER

    I spent a few hours playing with the .config files, if you edit the virtual host settings in 000-default.conf in the /etc/apache2/sites-available/ folder . I removed the Options Followsyslinks line. I don't know how this will effect security or performance, so I'll read up on that.

    *Note that this for apache version 2.4.18


  2. at google cloud service you can install apache2 and enbale .htaccess on it :’)

    Note to enable .Htaccess go to : /etc/apache2/apache2.conf

    and search this line :

    <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
    

    change to :

    <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search