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

and add the below content

After saving the file and exit.

Change its permision to 660

and change the owner of the file to be www-data

 

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

Add the below

After changes it should look like this

Also edit the file /etc/apache2/apache2.conf

and change as below

 

then you have one command to fire up things, run the below command

and restart apache

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