18

I've install on my apache2 server wordpress site but all permalinks doesn't work (404 not found) my .htaccess was generated by wp

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

My conf file for this site:

<Directory /home/sergey/siteName>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

anything from those answers does not help me

Thanks.

UPD:

Thanks to Justin Iurman's comment. Setting AllowOverride All in my conf solve the problem :)

Community
  • 1
  • 1
Sergey Cherepanov
  • 629
  • 2
  • 7
  • 19
  • 7
    First of all, do you have `mod_rewrite` enabled ? Then, you have defined a `RewriteBase` so you don't need leading slash in your second `RewriteRule` before `index.php`. Finally, change `AllowOverride None` by `AllowOverride All` in your conf – Justin Iurman Apr 30 '14 at 12:34
  • In such a case also the output of your Apache error logs for this domain will be helpful. Additionally, you can turn on logging for rewrite. http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritelog The output from the logs will probably helpful - if you can't figure it out by yourself paste the output from the logs in the question. – meberhard Apr 30 '14 at 12:36

3 Answers3

27

How to get WordPress permalinks / pretty links to work in Ubuntu 10.10 with Apache2:

By the way, this should be the same in Ubuntu 10.04 as well, but I haven't actually tested it there as well.

  1. Manually create a ".htaccess" file and save it in your main WordPress directory. (This is the one with the wp-admin, wp-includes, and wp-content folders.)

  2. Go to the Ubuntu terminal and type:

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

You should see a line printed saying that the (group) file ownership has been changed to www-data (Apache2).

  1. Give Apache2 write access to the file:

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

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

  1. Next, we have to allow WordPress to write to the .htaccess file by enabling mod_write in the Apache2 server. Type the following in the terminal:

sudo a2enmod rewrite

You should see a line printed saying that it is enabling mod rewrite and reminding you to restart the web server

  1. So let's do that. Restart the web server, Apache2, for the changes to take effect by typing:

sudo /etc/init.d/apache2 restart

We are all done with the command line prompt; you can close the command line window now.

  1. 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.

  2. DONE! Go to your site and check any page (other than your homepage) to ascertain that everything is working as expected.

Hope this helps someone.

Nmk
  • 1,281
  • 2
  • 14
  • 25
  • Works for me! Thanks! :) – Tarsis Azevedo Oct 21 '16 at 23:38
  • As i've already voted, cannot upvote anymore. But your answer has saved me multiple times. Thanks a ton :) – ashish.gd Oct 23 '19 at 14:38
  • Thank you, @ashish.gd, You can share this answer with related questions. it helps more people; – Nmk Nov 04 '19 at 09:23
  • Does not work for me. I did all the steps (double checked chown and chmod params), when I switch permalinks to ?p=id it works (I know, these are not permalinks just query strings), after every time I click save in permalinks settings I issued `cat .htaccess` to observe the change and actually Wordpress changes the file... – Marecky Dec 01 '20 at 17:10
22

After following the steps written by nmk,

sudo vim /etc/apache2/apache2.conf

Find the entry
<Directory /var/www/html>
and change
AllowOverride None
to
AllowOverride All

Then save file (:wq) and on command prompt restart apache2 service

sudo /etc/init.d/apache2 restart

nandan
  • 686
  • 8
  • 11
18
  1. open /etc/apache2/apache2.conf file.
  2. Change AllowOverride from value 'none' to 'All' as given below
<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
  </Directory>

3.Activate mod_rewrite

sudo a2enmod rewrite

4.Restart the apache server to put this changes to effect.

sudo apachectl restart
Vineeth Bhaskaran
  • 2,161
  • 1
  • 29
  • 36