Ubuntu 12.04 - LAMP - WordPress : .htaccess errors

Posted March 14, 2013 21.1k views
I created a LAMPed Ubuntu 12.04 droplet, fresh from the menu. Then added fred as a root user. Logged in as fred I installed Wordpress. Everything looks great, I can add posts to the blog, but ... I cannot change the permalinks setting in the Wordpress dashboard without getting a "You should update your .htaccess now" error. There IS NO .htaccess file. So I created one in /var/www/ with the suggested settings from the Wordpress error. After restarting the apache service I still get the error when attempting to change the permalinks setting. I've chmodded /var/www/ to 777 - still get the error. I'm about to go bald through pulling out my hair. Any suggestions?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

17 answers
Edit your VirtualHost config making sure AllowOverride is set to all.
To get Permalinks working you will need to place an .htaccess file in your wordpress's web directory 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

Please also revert the permissions back on the /var/www directory as running them in 777 is not safe security.

Also you can find a full write up on Permalinks here:
As I said, I created the .htaccess file with the suggested settings from the Wordpress error, which was exactly what you posted. Still no joy.
This helped me when I tried bring permalink to alive

a2enmod rewrite

Even though I changed permissions on /var/www/ to 777 on all files and subdirectories, I did not go back and check the .htaccess to confirm. It was still at 644. Changed it to 666 and the permalink update worked.

Thanks all.
I am having the same problem as above. I've tried all that has been recommended:

- Enabling modrewrite and restarting apache
- Setting .htaccess permission to 666, and ensuring that it was updated by the control panel

Am I missing anything else?
Same issue here. I'm pulling my hair out with this! I should add I'm attempting to do this with apache virtual hosts.
As well as adding the .htaccess file I had to run

`a2enmod rewrite`

and then

`service apache2 restart`

This solved my problem, hope it can help others :)
Can we confirm that var/www/ is the correct "root" folder for wordpress and updating/adding the .htaccess file?

Additionally, does this apply to DO servers for AllowOverride?
@eric: There isn't a "correct" root directory, it's just a matter of preference. You can host it anywhere you want. And yes, AllowOverride applies to DigitalOcean servers.
I spent way too many hours and recreating droplets over and over and just can't get the permalinks to work. I was hoping to have one of my sites up to test performance and what-not. Instead I just getting really annoyed.
@ mkstlouis:
Do you have multiple sites setup? If so make sure not to only edit:
(setting AllowOverride to all)
But any other site you have enabled in that directory will need the same 'AllowOverride all'
My environment: LAMP

What I did:

sudo a2enmod rewrite
sudo service apache2 restart
gedit /etc/apache2/sites-available

AllowOverride All

AllowOverride All

Make sure you change the AllowOverride to All

sudo service apache2 restart

Then change the permissions so that wordpress is able to modify the file. I believe someone posted it up above, or you can find it here
Mark Provan's answer fixed it for me, I didn't think to do the "a2enmod rewrite" command, and that's what fixed it.
yep, the AllowOverride in the Virtual Host config was the problem. Thanks.

i was running my wordpress server on var/www/public_html/blog

If i was changing permalinks with post name then it is showing 404 page. I tried many methods from this DO articles but nothing solved. help me with detailed instructions

Hope this will fix your problem who are facing even after going through all the steps

sudo nano /etc/apache2/sites-available/000-default.conf

add these lines below “Document root”

DocumentRoot /var/www/

<Directory /var/www/>
AllowOverride all

or in case of multiple websites

sudo nano /etc/apache2/sites-available/

add these lines below “Document root”

<Directory /var/www/>
AllowOverride all

then restart apache

Submit an Answer