The .htaccess file

The .htaccess file should be updated when you change the permalink setting.

The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 666. Then repeat the original solution. Don’t forget to change the permissions back to 660.

 

 

Local Apache Environment

 

Enable the rewrite_module in the Apache configuration

Go to the apache folder, then go to the configuration “conf” folder. on Mac the file is /etc/apache2/httpd.conf

Locate the httpd.conf file. Search for a line like this:

#LoadModule rewrite_module libexec/apache2/mod_rewrite.so

Simply get rid of the pound sign in front of it.

Give the permission to edit filesystem

Then search <Directory> </Directory> part:

Note there may be multiple parts like this, which are define different directories, my wordpress was installed under /var/www/html, so I will edit below part:

 

<Directory "/var/www/html">

# Possible values for the Options directive are "None", "All",

# or any combination of:

#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews

# Note that "MultiViews" must be named *explicitly* --- "Options All"

# doesn't give it to you.

#

# The Options directive is both complicated and important.  Please see

# http://httpd.apache.org/docs/2.4/mod/core.html#options

# for more information.

Options Indexes FollowSymLinks

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

#

AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted

</Directory>

On MAC, you will see following section:

# Apple specific filesystem protection.

#

<Files "rsrc">

    Require all granted

</Files>

<DirectoryMatch ".*\.\.namedfork">

    Require all granted

</DirectoryMatch>
mod_Rewrite

The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.

mod_rewrite provides a flexible and powerful way to manipulate URLs using an unlimited number of rules. Each rule can have an unlimited number of attached rule conditions, to allow you to rewrite URL based on server variables, environment variables, HTTP headers, or time stamps.

mod_rewrite operates on the full URL path, including the path-info section. A rewrite rule can be invoked inhttpd.conf or in .htaccess. The path generated by a rewrite rule can include a query string, or can lead to internal sub-processing, external request redirection, or internal proxy throughput.

http://httpd.apache.org/docs/current/mod/mod_rewrite.html

cache

 

Be sure to empty your browser cache, and your server cache.

Reference

http://www.wpbeginner.com/wp-tutorials/how-to-enable-custom-permalinks-in-wordpress-wamp-installation/

http://www.wpbeginner.com/wp-tutorials/how-to-fix-wordpress-posts-returning-404-error/