vendredi 23 septembre 2016

Set Up Url Rewriting in Ubuntu Apache2

  Aucun commentaire


Hey,
We are going to do some Url Rewriting with a couple commands.
I'm using Ubuntu 14.04 :D
sudo apt-get update
 sudo a2enmod rewrite
 sudo service apache2 restart
 sudo vi /etc/apache2/sites-enabled/000-default.conf
Inside that file, you will find the <VirtualHost *:80> block on line 1. Inside of that block, add the following block:
 <Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

           </Directory>

sudo service apache2 restart
Now, create the .htaccess file and put inside it the text below:

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L] 

Then,
sudo service apache2 restart
That's it, now you will be able to access to your .php files by changing the ".php" extension to ".html"

Aucun commentaire :

Enregistrer un commentaire