XAMPP and similar localhost web servers don't have mod_rewrite enabled. Also, the AllowOverride directive is often set to None, which causes Apache to ignore your .htaccess file. This can break WordPress permalinks, leading to "404 Not Found" errors when accessing posts.
If your URLs look like http://localhost/?p=2
instead of clean links like http://localhost/my-post
, the following section will help you fix permalinks and enable .htaccess support.
How to Enable WordPress Permalinks in XAMPP
- Open Apache’s Configuration File
Using a text editor (such as Notepad++ or VS Code), open the file:
\xampp\apache\conf\httpd.conf
- Enable
mod_rewrite
Search for this line:#LoadModule rewrite_module modules/mod_rewrite.so
Remove the
#
to uncomment it:LoadModule rewrite_module modules/mod_rewrite.so
- Allow .htaccess Overrides
Search forAllowOverride
until you find a section like this:# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig LimitAllowOverride All
# Controls who can get stuff from this server.
Order allow,deny
Allow from allMake sure the line reads:
AllowOverride All
- Save and Restart Apache
Save thehttpd.conf
file and restart your Apache server using the XAMPP control panel. - Update Your WordPress Permalink Settings
Log into your WordPress admin area, go to Settings → Permalinks, choose your desired permalink structure, and click Save Changes.
That’s it! WordPress permalinks should now work properly on your local XAMPP installation. Your .htaccess file will also be recognized and used as expected.