---
title: How to Redirect a Domain to a Subfolder Using .htaccess
description: "🌐This guide is also available in Arabic[← اقرأ بالعربية](https://kb.tarweig.com/docs/%d9%83%d9%8a%d9%81%d9%8a%d8%a9-%d8%a5%d8%b9%d8%a7%d8%af%d8%a9-%d8%aa%d9%88%d8%ac%d9%8a%d9%87-%d8%a7%d9%84%d9%86%d8%b7%d8%a7%d9%82-%d8%a5%d9%84%d9%89-%d9%85%d8%ac%d9%84%d8%af-%d9%81%d8%b1%d8%b9%d9%8a/) ## Clean Domain Redirection to Subdirectories If your website files reside in a subfolder (such as `public_html/mysite`) but you want visitors to access it directly via `example.com` without displaying the subfolder…"
url: "https://kb.tarweig.com/en/docs/how-to-redirect-your-domain-to-a-subfolder-using-htaccess/"
updated: "2026-10-11"
category: Getting Started
---

# How to Redirect a Domain to a Subfolder Using .htaccess

🌐This guide is also available in Arabic[← اقرأ بالعربية](https://kb.tarweig.com/docs/%d9%83%d9%8a%d9%81%d9%8a%d8%a9-%d8%a5%d8%b9%d8%a7%d8%af%d8%a9-%d8%aa%d9%88%d8%ac%d9%8a%d9%87-%d8%a7%d9%84%d9%86%d8%b7%d8%a7%d9%82-%d8%a5%d9%84%d9%89-%d9%85%d8%ac%d9%84%d8%af-%d9%81%d8%b1%d8%b9%d9%8a/)

## Clean Domain Redirection to Subdirectories

If your website files reside in a subfolder (such as `public_html/mysite`) but you want visitors to access it directly via `example.com` without displaying the subfolder in the URL bar, use the following Apache mod_rewrite rules.

### Configuration Rules:

Add these lines to the `.htaccess` file located in your primary `public_html` root directory (replace `example.com` and `subfolder` with your actual values):

```
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/subfolder/
RewriteRule ^(.*)$ /subfolder/$1 [L]
```

**Note:** Ensure you edit the root `.htaccess` file. You can easily modify it in cPanel File Manager by ensuring *Show Hidden Files* is enabled.
