After strugling and googleing for a long time, scratching my hair to make this issue resolved, it took lots of my time to come into a conclusion and resolve the issue.
First of all on the directory where the site is hosted, there should be a .htaccess file and you can see it by changing your working directory to your web directory and type the below command to see it
ls -la
this command will list all the files in that directory using the l which is list and a which will show hidden files.
if you dont have the file, please create it using the blow command and add the content below
1 |
sudo touch .htaccess |
1 |
sudo vim .htaccess |
and add the below content
1 2 3 4 5 6 7 8 9 10 11 |
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress |
After saving the file and exit.
Change its permision to 660
1 |
chmod 660 .htaccess |
and change the owner of the file to be www-data
1 |
chowner www-data:www-data .htaccess |
At this point the marathon is not over, we need to edit the directory access on apache to allow .htaccess overide some configurations on the apache web server, Edit the below file and add some configurations
1 |
/etc/apache2/sites-available/000-default.conf |
Add the below
1 2 |
ServerAdmin webmaster@domain.com DocumentRoot /var/www/html |
After changes it should look like this
1 2 3 4 5 6 |
ServerAdmin webmaster@domain.com DocumentRoot /var/www/html <Directory /var/www/html> Options +FollowSymLinks AllowOverride All </Directory> |
Also edit the file /etc/apache2/apache2.conf
and change as below
1 2 3 4 5 |
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride ALL Require all granted </Directory> |
then you have one command to fire up things, run the below command
1 |
sudo a2enmod rewrite |
and restart apache
1 |
/etc/init.d/apache2/restart |
Here your ready to test the permalinkg after you change and update.
Things will come as expected from here.
Try it and see it for yourself, drop us a comment if this helps you
Thanks and mostly welcome