Wordpress (Postname Permalink) 404 error

2019-09-09 21:12发布

问题:

I have a problem with my Wordpress permalink. I tried to change permalink to postname "/%postname%/". When I test one of my page, its says that 404 Not Found.

I've looking around about my problem and tried many tutorials but no luck. In my opinion, my Wordpress access seems not working but I'm not sure because I'm newbie for this. Please anyone can help me solve this problem.

Thanks In Advance

回答1:

Try replacing your .htaccess with default .htaccess

# 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

Make sure you backup your .htaccess before using this.



回答2:

If your .htaccess file were writable, WordPress will do this automatically, but if it isn't- these are the mod_rewrite rules you should add in your .htaccess file.

1- Open .htaccess file and copy the following data in that file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
  1. After updating the file the permalink issue will resolve.


回答3:

Please check you .htaccess must look like below if not remove all code and write below:

    # 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

After that run below command:

1 EDIT (Change None to all) sudo vim /etc/apache2/apache2.conf

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

To (press i to edit)

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

save (press :wq!)

  1. sudo a2enmod rewrite

  2. sudo service apache2 restart



标签: wordpress