How to make WordPress Permalinks work in Xampp

How to Fix WordPress Permalinks in XAMPP: If your WordPress URLs look like http://localhost/?p=2 instead of clean links like http://localhost/my-post, it's usually because mod_rewrite is not enabled or Apache is ignoring your .htaccess file. The following steps will help you enable permalinks and .htaccess support in XAMPP.

  1. Open Apache's Configuration File
    Using a text editor (Notepad++, VS Code, etc.), open:
    \xampp\apache\conf\httpd.conf
  2. 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
  3. Allow .htaccess Overrides
    Search for the AllowOverride directive. You should find a block 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 Limit
    
    AllowOverride None
    
    # Controls who can get stuff from this server.
    Order allow, deny
    Allow from all

    Change the line AllowOverride None to:

    AllowOverride All

    This ensures Apache will read your .htaccess file.

  4. Save and Restart Apache
    Save the httpd.conf file and restart Apache from the XAMPP Control Panel.
  5. Update Your WordPress Permalink Settings
    Log into your WordPress admin dashboard, go to Settings → Permalinks, choose your preferred permalink structure, and click Save Changes.

That's it! permalinks should now work properly on your local XAMPP installation, and your .htaccess file will be recognized and used as expected.