D_R
D_R

Reputation: 4962

Redirection of subdirectory to parent subdirectory

I have the following file structure

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

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

this one does it all, expects it redirects to /api/ instead of /api/web.

RewriteEngine On

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

Upvotes: 1

Views: 43

Answers (1)

anubhava
anubhava

Reputation: 785146

Place this rule in root .htaccess (1 level above app directory):

RewriteEngine On

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

Upvotes: 1

Related Questions