WordPress permalinks in ubuntu with Apache2

Hey there.. welcome to my new blog post “WordPress permalink in ubuntu”. I have seen lots of people facing problem to make it work wordpress permalinks / pretty links and searching various sites / forums to find solution. So if you are here, then I am sure you are on the right page…. 😀

Steps to fix this issue:-

  • If you do not have .htaccess file in your  wp root directory then manually create .htaccess  file and save it.
  • Open Ubuntu terminal and type and click enter:-

sudo chown -v :www-data "/wp_root_directory_path/.htaccess"

You should see a printed line “changed ownership of `xyz/.htaccess’ from user_name:user_name to :www-data”. If yes then file ownership has been changed to “www-data”.

  • File permission:- Give write access to the file:

sudo chmod -v 664 "/wp_root_directory_path/.htaccess"

You should see a line printed that the mode of the file has been retained.

  • Allow wordpress to write to the .htaccess file by enabling mod_write.


sudo a2enmod rewrite

After enter this command through terminal you will see a printed line that it is enabling mod rewrite and reminding you to restart the web server

    • Restart Web Server:-

sudo /etc/init.d/apache2 restart

We are done with command line, now we can close terminal 🙂

  • Go into your WordPress admin panel (i.e. http://yourDomain/wp-admin). Go to the Settings –> Permalinks and select the permalink format of your choice. Hit the “Save Changes” button.
  • DONE! Go to your site and check any page (other than your homepage) to ascertain that everything is working as expected.


I hope this blog helps someone to make it work permalinks, please feel free to comment it below.

Leave a Reply

Your email address will not be published. Required fields are marked *