How to Remove File Extension (.php or .html) from URL on UbuntuServer

As from the SEO point of view it is better to don’t use file extensions so that you have user-friendly URLs on your site. For Example,lets take ( https://www.example.com/index.html ) you want to have it as ( https://www.example.com/index ).

Let’s start integration:

Having Trouble in configuring ubuntu server on google cloud ,check this detailed blog 

https://nectarspot.com/how-to-host-amp-web-applications-on-google-cloud-platform/

Once the Setup is done on your ubuntu server,just follow the commands below and paste on your server.

Lets get into your root folder 

sudo su

cd

sudo nano /etc/apache2/apache2.conf

Now Scroll down till you find the directory var/www and paste the following code there

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule (.*) $1.php [L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1.html [L]
</IfModule>

Now CTRL+X and then you get option yes or no,click yes and just restart apache2 server

sudo service apache2 restart

Thank you !! Visit us again

Looking for a Top Rated* Marketing Company?

Contact us at +1 630 999 SPOT (7768) or submit a business inquiry online.