Wednesday, March 1, 2023

wordpress error 404 when set Permalink structure as Post Name

Hello

I face many time 404 error when I set "Permalink structure" as "Post Name". Here I gave you my solution for this.

Go to your wordpress directory and make .htaccess file and put this code:


<IfModule mod_rewrite.c>

RewriteEngine On

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /real611/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /real611/index.php [L]

</IfModule>


Here "real611" is your wordpress folder name. You have to replace it with your wordpress folder name.



Create file "wp.conf" in /etc/apache2/sites-available/wp.conf

by commands, do these steps:-

1. Go to this folder and open terminal from this folder "sites-available" and type this command : sudo vi wp.conf

You will be notifiy for enter password.

2. After entered password, editor is open. Copy paste this code.



<Directory /var/www/html/>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>



3. Now save this file by this commands.

To save a file in Vim / vi, press Esc key, type :w and hit Enter key

One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key





4. Now restart your web server details below:

  1. sudo a2ensite wp.conf
  2. systemctl reload apache2
  3. service apache2 reload
  4. sudo a2enmod rewrite
  5. systemctl restart apache2


Now you can set "Permalink structure" as "Post Name"

No comments:

Post a Comment