Baba Tech Blog

TR EN

Activating .htaccess on XAMPP (Illustrated Guide)

This article is older than 2 years. Some information might be outdated.

Activating .htaccess on XAMPP (Illustrated Guide)#

While working on localhost, the .htaccess file provides great convenience in many matters such as SEO settings, hotlink prevention, custom error pages, and traffic control.
In this post, I will show you step-by-step how to activate the .htaccess file using XAMPP.


1️⃣ Enabling the Apache Mod Rewrite Module#

  1. Open the XAMPP Control Panel.
  2. Click the Config button located to the right of the Apache line.
  3. Select the httpd.conf file from the opening menu. Xampp Httpconf

🧩 Then find the following line:

#LoadModule rewrite_module modules/mod_rewrite.so

Remove the # (hash) sign at the beginning:

LoadModule rewrite_module modules/mod_rewrite.so

This process allows URL redirection and rewriting operations to work.


Xampp Httpconf Config

2️⃣ Changing the AllowOverride Setting#

Find the following lines in the same file:

AllowOverride None

and change them as follows:

AllowOverride All

This change allows the .htaccess file to work actively.


3️⃣ Restart Apache and MySQL Services#

For the changes you made to take effect: Return to the XAMPP panel and restart Apache and MySQL services by clicking Stop → Start.


4️⃣ Sample .htaccess File#

Now your .htaccess file is active! To try it, create a .htaccess file in the root directory and add the following code:

# Activates redirections
RewriteEngine On

# Example: redirect non-www to www
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

🧠 Additional Information#

  • The .htaccess file works on Apache servers.
  • The filename must start with a dot (.) and must not have a file extension.
  • After editing the file, don't forget to clear the browser cache.

Good luck 😉 Now your .htaccess file is working with full functionality on XAMPP.

Webmentions

Likes

  • Loading likes...

Comments & Replies

  • Loading comments...

Comments
Reply via Bluesky

With an account on the Fediverse or Mastodon, you can respond to this post.

Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.

Loading comments...