A friend of mine working in localhost and when he try to change the permalink structure to a custom permalink or to any other permalink and unfortunately all his site pages goes to 404 error page not found and he could only access the default permalink structure which is e.g. http://localhost/?p=1, this time I will try to explain why it happen and give you possible solution.
Okay, let’s start.
The reason why it happen is because Apache module mod_rewrite and AllowOverridedirective are both disable by default and if you change permalink structure, WordPress use .htaccess files and in order for .htaccess to work properly you need to enable Apache module and AllowOverride directive that is usually set to none.

Solution:

Method 1:

Step 1:

Start the server you’re using in your wordpress installation, this tutorial I’m using WAMP server, if you’re use XAMP or any other server don’t worry folks the solution is the same.
After you start the server you will now see green icon directly right beneath the taskbar, if you didn’t see it click show hidden icons to show more icons.

Step 2:

Click the green icon and select Apache -> httpd.conf, it will open httpd.conf in notepad.

Step 3:

And now the httpd.conf is open in notepad, press Ctrl + F to search, typemod_rewrite.so in the text field.
You notice that the line has hash “#” on the left side; now all you need to do is remove the hash
Fom
Apache
1
#LoadModule rewrite_module modules/mod_rewrite.so
To
Apache
1
LoadModule rewrite_module modules/mod_rewrite.so
Now search AllowOverride until you reach something similar below.
Apache
1
2
3
4
5
6
7
8
9
10
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride None
#
# Controls who can get stuff from this server.
#
Change the above lines to these.
Apache
1
2
3
4
5
6
7
8
9
10
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be “All”, “None”, or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
After changing those lines above, now save the file.

Step 4:

In order the changes to take effect you need to restart services, to do that click the green icon or the WAMP server icon and click Restart All Services, wait for a few seconds until the green icon back to its original color.

Method 2:

Now instead of editing httpd.conf which is quite long method will do just check the module we want to enable and it’s pretty easy.
Select Apache –> Apache Modules –> and that will display the lists of available modules now just check rewrite_module
That’s it and you’re done.
Thanks to jhezer for pointing this method.
That’s it, change the permalink structure again and refresh your site.
Let me know if you’re in any trouble, use the comment box below to add your thoughts.

0 comments:

Post a Comment

 
Top