Remove Index.php From URL
- Article
- Comment
Introduction
Remove Index.php From URL. Sometimes your website requires to keep use of index.php f
or indexing the pages. This is not necessary for our url and it looks ugly to see all of our site urls. So we need to remove it from the url. By enabling the mod_rewrite
it will be solved. To enable it the rewrite module, run “apache2 enable module rewrite”:
sudo a2enmod rewrite
Once you update the configurations or settings. You need to restart the webserver to apply the changes:
sudo service apache2 restart
If you plan on using mod_rewrite in .htaccess
files, you also need to enable the use of .htaccess
files by changing AllowOverride None
to AllowOverride FileInfo
.
For the default website, edit /etc/apache2/sites-available/default
: or /etc/apache2/sites-available/apache2.conf
.
Configuration
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews # changed from None to FileInfo AllowOverride FileInfo Order allow,deny allow from all </Directory>
After making changes you need to save and, you need to restart Apache again.
Saving does not work sometimes, if you have the access permission problems. Let’s change the permission before saving it.
sudo chmod 777 /etc/apache2/sites-available/default/000-default.conf
Than you can rewrite your .htaccess
file to take effect in it. If you are interested to know more tutorials and tips from me. Just follow and subscribe my channel to get more updates. Don’t worry I don’t spam your inbox. You can select appropriate category to receive emails from that particular articles. Also if you are interested you can follow me on different social sites. follow me with bellow listed sites.