-1

I have an app in folder /var/www/test Also there is an "sub-app" in folder /var/www/test/subapp

There is another index.php inside /var/www/test/subapp and if user will type test.com the index.php from /var/www/test should trigger but when user type test.com/triggersubapp the index.php from /var/www/test/subapp shall run.

I failed to create correct statements and RewriteRules and I haven't got much time left.

So have any one of You know how to do this easiest way or maybe have a correct definition?

I would greatly appreciate it !!!

EDIT 1: I need to have something like different DocumentRoot - RewriteRules don't apply!!

EDIT 2 The main index.php and .htaccess are in /var/www/test/public/. :(

Froggiz
  • 3,013
  • 1
  • 18
  • 30
Mr.TK
  • 99
  • 3
  • possible duplicate of [Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About Mod\_Rewrite Rules but Were Afraid to Ask](http://serverfault.com/questions/214512/redirect-change-urls-or-redirect-http-to-https-in-apache-everything-you-ever) – BE77Y May 12 '15 at 11:07
  • @BE77Y I need to have something like different DocumentRoot - In my opinion RewriteRules don't apply. It's not a duplicate of the answer provided by You. Please read carefully my question once again. I am having two different index.php files in different directories - only subfolder in url should decide which index.php shall be triggered. PS: I'm still thinking about editing v-hosts. Maybe .htaccess is an option as Ahmed I. suggested in his answer in this thread. – Mr.TK May 12 '15 at 11:26
  • OK - I based that flag on, to quote your post, _"I failed to create correct statements and RewriteRules"_ - and the article I linked to is canonical on the topic of RewriteRules, meaning the community does not wish to say any more on the topic. If you are saying that RewriteRules do not apply, please update your question to clarify. – BE77Y May 12 '15 at 11:53
  • I said "in my opinion". I wish You could show me that I am being wrong here. As Ahmed I. did. ;) Hope his answer will work. – Mr.TK May 13 '15 at 06:15
  • You're not giving us enough to go on. Please read http://serverfault.com/help/how-to-ask – Jenny D May 15 '15 at 08:54

1 Answers1

1

You need to have an .htaccess file inside /var/www/test/subapp/ and the rewrite rules should be written for that index.php

Also try to ignore /subapp/ URL from /var/www/test/.htaccess

serverliving.com
  • 875
  • 6
  • 15
  • But how will subapp know that it has to trigger? "Test" is the main app and it's triggered by default. So there should be .htaccess at /var/www/test/ that will trigger /var/www/test/subapp/index.php but I have no idea how to trigger that. – Mr.TK May 12 '15 at 11:31
  • The rewrite rule for loading subapp will be something like below RewriteRule ^(.*)$ /subapp/index.php [L] . Also note that you need to exclude this path from main rewrite rule.Can you paste your main htaccess file here? – serverliving.com May 12 '15 at 12:04
  • Oh... i think that I will have a problem here. Main .htaccess and index.php in in /var/www/test/public folder ;/ Will rewrite be able to go one folder up? – Mr.TK May 13 '15 at 06:36