Nenad Milosavljevic
Nenad Milosavljevic

Reputation: 147

Redirect without changing Url htaccess

I'm wondering if this is possible - I have projects structured like:

www.mydomain.com points to MyFolder on server. In MyFolder i have 3 App Folders eg MyFolder/App1, MyFolder/App2..

Each of these are 3 different web applications. Url of domain is www.mydomain.com Is it possible, that, when url user go to mydomain.com, it automatically redirect to mydomain.com/App1 but without url change visible to user (in browser it will still be mydomain.com)? I can not point domain to MyFolder/App1 because that way app2 is not accessible. My solution is that app1 becomes a root which contains app2,app3 etc folder but thats just to messy edit: question clarification

Upvotes: 1

Views: 3399

Answers (2)

Panama Jack
Panama Jack

Reputation: 24448

You should be able to use this code here.

RewriteEngine on
#ignore App1 and App2 and interally Rewrite to /App
RewriteCond %{REQUEST_URI} !(App1|App2) [NC]
RewriteRule ^(.*)$ /App/$1 [L]

Upvotes: 1

Claudiu Creanga
Claudiu Creanga

Reputation: 8366

Yes, you should be able to do it in your .htaccess file like this (untested code):

RewriteCond %{HTTP_HOST} ^example.com/App
RewriteRule ^(.*) http://www.example.com/App1 [P] 

Upvotes: 0

Related Questions