How to Enable HTACCESS Support on Apache server in Digitalocean

In this tutorial, we are going to see about Steps to Enable HTACCESS Support on Apache server in Digitalocean.

HTACCESS Plays the Main Role in Apache Web server.We can add the Custom Rewrite Rules for

  • WWW and NON-WWW Redirection
  • Force SSL
  • SEO Friendly URL
  • GZIP Compression
  • And Much More

In Digitalocean we need to Enable a mod_rewrite to use HTACCESS in Apache web server also we need to add Directory Rule to Enable an HTACCESS Support on Apache server.

This tutorial for Apache2 Server Which Installed on Ubuntu Operating System

Here are the Steps to Enable HTACCESS Support on Apache server in Digitalocean

Step -1

Enable Mod_Rewrite for Apache web server

  • Run to Below command line to Enable the Mod_rewrite for Apache
sudo a2enmod rewrite
  • After activating the Mod_rewrite restart the apache server
sudo service apache2 restart

Step – 2

Enable an HTACCESS File Support This Step for NON-SSL Websites/blogs

  • Open /etc/apache2/sites-available/000-default.conf
sudo nano /etc/apache2/sites-available/000-default.conf
  • Add this Below rule on 000-default.conf File
<Directory /var/www/html>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
 </Directory>
  • Add this rule between *<VirtualHost :80>
<VirtualHost *:80>

<Directory /var/www/html>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
 </Directory>

</VirtualHost>
  • Save and Restart the Apache server
sudo service apache2 restart
  • That’s all Successfully we Enable HTACCESS Support on Apache server in Digitalocean

Enable HTACCESS for SSL Enabled Domain

  • Open default-ssl.conf File
sudo nano /etc/apache2/sites-available/default-ssl.conf
  • Add this Below rule on that File same as Step 2 add this below rule between
<Directory /var/www/html>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
 </Directory>
  • Save and Restart the Apache web server
sudo service apache2 restart

Enable HTACCESS Support on Apache server Using Nginx as Reverse Proxy

We are using Nginx as reverse proxy on LAMP Stack we try to add this rule in the default file but it’s not working due to virtual host port Modification(Nginx reverse Proxy Setup) after that we try this Rule on apache.2 conf File it’s giving good result 🙂

  • Open apache2.conf File
sudo nano /etc/apache2/apache2.conf
  • add this below rule on apache2 File
<Directory /var/www/html>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride All
 Order allow,deny
 allow from all
 </Directory>
  • Save the File & Restart the server
sudo service apache2 restart
  • Now you create a .htaccess on your web Folder  🙂 and add your Rewrite rules…
var/www/html/.htaccess

How to Guides