redirect only domain.com to domain.com/subfolder/index.php not domain/whatever

177 views Asked by At

If user request existing php code, which I placed right in the root:

  • domain.com/images/pic1.jpg
  • domain.com/anyphp.php
  • domain.com/someapp/somecode.php
  • domain.com/anything.someExt
  • etc

don't do anything,leave as it, they are working good.

But if he simply enter domain.com -> send him to domain.com/myNewApp/index.php, which is my cool new app. Don't rewrite the URL to domain.com/index.php because it is for my existing app.

I expect the answer may be super simple but I am just giving up trying

2

There are 2 answers

0
Phung D. An On BEST ANSWER

DirectoryIndex oxwall/index.php

Simple but it works

1
Mark Anderson On

Do you have access to the Apache conf file? If so:

RewriteEngine  on
RedirectMatch ^/(.*)$ http://example.com/myNewApp/index.php

Should work.

Edit: This rewrite won't work. I never used the regex-capture. And I misread what you wanted. It looks like you found an answer, but this should still work if you change the regex to:

RewriteEngine  on
RedirectMatch ^/$ http://example.com/myNewApp/index.php

Check out this page for more re-writey goodness: http://httpd.apache.org/docs/current/rewrite/remapping.html