0

I have created a WordPress Website on my local PC. When I open the website at local it working fine me for Homepage, but I open another page it redirects me to 404 page. When I change Permalink from post to ID it is open all pages.

I have done the following thinks but unable to get the solution.

  1. Create new .htaccess file.
  2. Create Virtual host at local PC.

Thanks in Advance.

Vishal Gupta
  • 903
  • 9
  • 26
  • share the htacess code here – Vel Aug 09 '18 at 12:32
  • Possible duplicate of https://stackoverflow.com/q/19400749/2869093 – FIL Aug 09 '18 at 12:35
  • Is your system Linux (Ubuntu) or Windows? If Ubuntu follow this link https://www.digitalocean.com/community/questions/wordpress-permalinks-not-working-on-ubuntu-14-04 or https://wordpress.stackexchange.com/questions/167144/wordpress-permalinks-not-working-in-apache2-ubuntu-14-04 – Shashank Sharma Aug 09 '18 at 12:36
  • Does this answer your question? [wordpress permalinks not working - htaccess seems ok but getting 404 error on pages](https://stackoverflow.com/questions/19400749/wordpress-permalinks-not-working-htaccess-seems-ok-but-getting-404-error-on-pa) – Stephen Ostermiller Oct 10 '22 at 11:02

4 Answers4

0

Looks like the link you put for that page, points to a wrong page(with ID). Check the links in menu, not only permalinks.

Simion
  • 353
  • 1
  • 9
0

Please check your rewrite rules in apache.

If rewrite rules are not enabled in apache server then this issue occurs.

Yogesh Garg
  • 299
  • 3
  • 10
0

If you want to use permalinks, you will need to make a change inside another file: apache > Conf and find the file httpd.conf.

Open that in a text editor, and use the search facility in the editor to find "rewrite". The line you need looks like this:

#LoadModule rewrite_module modules/mod_rewrite.so

You need to take away the hash sign so it looks like this

LoadModule rewrite_module modules/mod_rewrite.so

Now just save the file.

Kirk Beard
  • 9,569
  • 12
  • 43
  • 47
0

Step1: Enabling mod_rewrite Now, we need to activate mod_rewrite.

sudo a2enmod rewrite This will activate the module or alert you that the module is already in effect. To put these changes into effect, restart Apache.

sudo service apache2 restart

Step2: Setting Up .htaccess In this section, we will setup a .htaccess file for simpler rewrite rule management.

A .htaccess file allows us to modify our rewrite rules without accessing server configuration files. For this reason, .htaccess is critical to your web application's security. The period that precedes the filename ensures that the file is hidden.

We will need to set up and secure a few more settings before we can begin.

First, allow changes in the .htaccess file. Open the default Apache configuration file using nano or your favorite text editor.

sudo nano /etc/apache2/sites-enabled/000-default.conf Inside that file, you will find the block on line 1. Inside of that block, add the following block:

/etc/apache2/sites-available/default

<Directory /var/www/html>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
</Directory>

Your file should now match the following. Make sure that all blocks are properly indented.

/etc/apache2/sites-available/default

<VirtualHost *:80>
    <Directory /var/www/html>

        . . .

    </Directory>

    . . .
</VirtualHost>

To put these changes into effect, restart Apache.

sudo service apache2 restart Now, create the .htaccess file.

sudo nano /var/www/html/.htaccess

Add this first line at the top of the new file to activate the RewriteEngine.

/var/www/html/.htaccess
RewriteEngine on

Save and exit the file.

To ensure that other users may only read your .htaccess, run the following command to update permissions.

sudo chmod 644 /var/www/html/.htaccess

You now have an operational .htaccess file, to govern your web application's routing rules.

Vishal Gupta
  • 903
  • 9
  • 26