what
what

Reputation: 348

Need help on htaccess redirect

I would like to install a WP under main folder, and redirect all the traffic to it, expect any visit to domain.com/api, domain.com/mobile.

cases:

  1. www.domain.com --> redirect to www.domain.com/main (main is hidden, I got this)
  2. www.domain.com/api --> no redirect needed
  3. www.domain.com/mobile --> no redirect needed

I've try few setting for htaccess, but I can not all cases works. Can anyone help me out here?

Big thanks in advance.

|--main
|   |-- index.php  
|--api
|--mobile
|--.htaccess


RewriteEngine On    
#  Change root directory to "main" folder
RewriteCond %{THE_REQUEST} ^GET\ /main/
RewriteRule ^main/(.*) /$1 [L,R=301]
RewriteRule !^main/ main%{REQUEST_URI} [L]

Upvotes: 1

Views: 22

Answers (1)

anubhava
anubhava

Reputation: 785146

Change your last rule to:

RewriteRule !^(main|api|mobile)/ main%{REQUEST_URI} [L,NC]

Upvotes: 1

Related Questions