wordpress permalinks not working - htaccess seems ok but getting 404 error on pages

前端 未结 10 1102
[愿得一人]
[愿得一人] 2020-12-07 19:16

I updated the permalink structure to /%postname%/ and this updated my .htaccess with:

# BEGIN WordPress

RewriteEngine On
Rewri         


        
相关标签:
10条回答
  • 2020-12-07 19:37

    Users of WAMP (Windows): Some versions of WAMP (all versions?) do not enable mod_rewrite or permit following SymLinks by default. To enable the required functionality navigate to the apache/conf/httpd.conf file, open with a text editor and uncomment the line LoadModule rewrite_module modules/mod_rewrite.so (i.e., delete the hash/pound sign at the front of the line). Then further down in the same file there is a section that starts with the line "Options FollowSymlinks". Change the second line in that section from "AllowOverride none" to AllowOverride all. Save edited httpd.conf and restart all WAMP modules. Your permalinks should now work.

    For more details, Fixing Permalink Problems

    0 讨论(0)
  • 2020-12-07 19:38

    For other people landing on this page - Another issue could be (If you are using Apache as your web server) is your httpd.conf or your sites-available/sitename.conf file needs editing.

    Your web directory will need to allow the .htaccess file to override it's settings.

    look for your web dir in the file - it will be in the bulk of the conf file or segregated into a VirtualHost section.

    <Directory /path/to/site>
         #add the following setting to allow .htaccess in your web dir to work
         AllowOverride FileInfo
    
         #other settings ---
    
    </Directory>
    

    This will allow you to set up WordPress URLs however you want, within WordPress.

    ***Edited - Thank You nietonfir For update. Use the least amount of privilege at first. If this doesn't work then replace AllowOverride FileInfo with AllowOverride All

    0 讨论(0)
  • 2020-12-07 19:42

    I was facing with the same problem and had one more thing to look for.

    Here is what you need to do for wordpress permalinks work properly:

    1. Make sure you have the proper permission modes for files and folders in your wordpress directory:
      sudo find . -type f -exec chmod 644 {} +
      sudo find . -type d -exec chmod 755 {} +

    2. For permalink structure make sure mode_rewrite is enabled in apache:
      sudo a2enmod rewrite
      sudo service apache2 restart

    0 讨论(0)
  • 2020-12-07 19:43

    There can be multiple things preventing the rewrite rule from working. My ubuntu server needed 3 things changed to get permalinks working.

    In newer versions of apache2, you need to enable the module:

    sudo a2enmod rewrite
    sudo service apache2 restart
    

    You may also need to modify the apache2.conf file.

    sudo nano /etc/apache2/apache2.conf
    

    Change your web directory override rule to AllowOverride All.

    <Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    

    After that, restart the service again.

    The .htaccess file in the WordPress install directory needs to be owned or readable/modifiable by the webserver.

    This can be accomplished by changing owner to www-data (usually the webserver user), or changing permissions.

    sudo chown www-data /var/www/wordpress-install/.htaccess 
    

    OR

    sudo chmod 664 /var/www/wordpress-install/.htaccess
    

    Login to your Wordpress admin backend and save the permalink settings, and they should hopefully be working.

    0 讨论(0)
提交回复
热议问题