I'm trying to remove index.php on my URL (localhost). I've followed the steps from this and because it wasn't working, I tried this. What happen? What should I do?
-
please check with =phpinfo() ?> mod_rewried is enable or not? if not you have to enable in your apache configuration. – umefarooq Jul 15 '19 at 07:20
1 Answers
If you are on linux there are a few extra steps you need to take care of:
Use the a2enmod command to enable the module:
sudo a2enmod rewrite
Then restart Apache.
sudo systemctl restart apache2
mod_rewrite is now fully enabled.
But by default, Apache prohibits using an .htaccess file to apply rewrite rules, so first you need to allow changes to the file. Open the default Apache configuration file using nano or your favorite text editor.
sudo nano /etc/apache2/sites-available/000-default.conf
Then add the following new block to /etc/apache2/sites-available/000-default.conf
so your configuration file looks like the following. Make sure that all blocks are properly indented.
<VirtualHost *:80>
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
. . .
</VirtualHost>
Save and close the file. To put these changes into effect, restart Apache.
sudo systemctl restart apache2
Now, create an .htaccess file in the web root.
sudo nano /var/www/html/.htaccess
Add this line at the top of the new file to activate the rewrite engine. /var/www/html/.htaccess
RewriteEngine on
Save the file and exit.
Not it should work just fine.
If you are using xampp
it is supposed to be enabled by default.
On windows

- 2,085
- 2
- 9
- 21