D_R
D_R

Reputation: 4962

Redirect subdirectory to parent folder

I have the following file structure

- example.com
- - app
- - - index.html
- - api
- - - index.php

How can I redirect my domain local.example.com to app/* and local.example.com/api/ to api/* ?

Upvotes: 1

Views: 86

Answers (1)

Justin Iurman
Justin Iurman

Reputation: 19016

Assuming local.example.com's document root is example.com folder...

You can put this code in your htaccess (which has to be in root folder example.com)

RewriteEngine On

RewriteCond %{HTTP_HOST} ^local\. [NC]
RewriteRule ^(?!(?:api|app)/)(.*)$ /app/$1 [L]

Upvotes: 1

Related Questions