Wednesday 25 December 2013

How to enable Permalinks in WordPress (Ubuntu)

Few days back I was facing trouble how do I use pretty Permalinks of WordPress which on first place were not working as per my settings so I followed these steps and solved my problem.

To enable Permalinks in WordPress (Ubuntu), You need to enable mod_rewrite of Apache and .htaccess.


Steps required:

Open your terminal and enable rewrite module of apache
sudo a2enmod rewrite
After this you need to restart apache server 
Type in terminal
service apache2 restart
To get Permalinks working you will need to place an .htaccess file in your wordpress’s web directory (/var/www or /var/www/ in case of multiple blogs on same host) and add the following:


             # BEGIN WordPress 
                RewriteEngine On 
                RewriteBase / 
                RewriteRule ^index\.php$ – [L] 
                RewriteCond %{REQUEST_FILENAME} !-f 
                RewriteCond %{REQUEST_FILENAME} !-d 
                RewriteRule . /index.php [L] 
             # END WordPress 



Change the permissions on the .htaccess file to “chmod 666″ so wordpress can update it when you change permalink structures from wordpress settings page

Note: This is a hidden file so it will only show up when you type “ls -altr“


Open up the following file, and replace every occurrence of “AllowOverride None” with “AllowOverride all” (note : “all” should be in lower-case for this to work)


sudo nano /etc/apache2/sites-available/default 
sudo service apache2 restart

Modify the permalink in WordPress admin panel (http://your-wordpress-domain/wp-admin.php) to what you need by visiting Settings -> Permalinks -> and clicking to “Save Changes”. 

This will update the .htaccess file. Double-check this by checking the timestamp of the .htaccess file after clicking “Save changes” on WordPress admin panel.





No comments:

Post a Comment