Before diving into the article let me give you the output which you’ll be able to see after performing the coming operations in the article. If you wordpress site currently displays URLs like https://abc.com/?post=123 or https://abc.com/index.php/page/test-post then this is the right article for you to follow. By following this you’ll be able to get rid of those ugly URLs and make them something like https://proappdev.com/php/hello-world/.
I highly recommend to follow this tutorial to install basic WordPress setup. But remember its a basic setup not the production ready with friendly URLs so there are more steps involved to achieve that which I would like to highlight below.
Make sure that mod_rewrite is enabled on your server setup, to check this do following.
– Create phpinfo.php file in
– Place this code inside
– Now save the file and visit https://yoursite.com/phpinfo.php, now find mod_rewrite in that if you see it then move ahead otherwise continue with this
sudo a2enmod rewrite
sudo systemctl restart apache2
Now at this stage we can now move ahead.
Edit the configuration file
sudo vi /etc/apache2/sites-available/yoursite.com.conf
Now modify the configurations as below
<VirtualHost *:80> <Directory /var/www/html/yoursite.com/public_html> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> ServerName yoursite.com ServerAlias www.yoursite.com ServerAdmin email@example.com DocumentRoot /var/www/html/yoursite.com/public_html ErrorLog /var/www/html/yoursite.com/logs/error.log CustomLog /var/www/html/yoursite.com/logs/access.log combined </VirtualHost>
At this stage we are done with configurations, time to move to wordpress admin to make our URLs friendly.
WordPress Admin >> Settings >> Permalinks now you’ll be able to see the following screen
Now you can choose any friendly slug that you like and then click on save changes. Now you should be able to see your URLs in friendly form without