0

I was using PHP for several website in a domain. But in the domain, there are several directories that should also can be accessed as a website. The structure of the www root is like this:


DOMAIN (www root)
|
|---> servicesApi (should accessible)
|
|---> anotherWebFolder (should accessible)
|
|---> webFolder
    |
    |--> subFolder1/subFolder/index.php (domain redirect here "http://mysite")
    |
    |--> subFolder2/subFolder/index.php (domain admin redirect here "http://mysite/admin")

What I like to achieve is:

  1. The domain (main site) should go to "webFolder/subFolder1/subFolder" without the name of "webFolder/subFolder1/subFolder" in the URL.

  2. Sub domain (http://mysite/admin) should go to "webFolder/subFolder2/subFolder" with URL name "http://mysite/admin"

  3. I need the other directories (servicesApi and anotherWebFolder) can be accessed normally (http://mysite/servicesApi and http://mysite/anotherWebFolder)

I've tried to use .htaccess file in the www root to redirect and remove the directory name in URL, but the other directories (servicesApi) cannot be accessed.

I've using index.php in the www root directory to redirect into the webFolder > subFolder1 > subFolder, but the folder name is exist in the url like this: http://localhost/webFolder/subFolder1/subFolder/index.php

Any suggestion?

========> EDITED <========== MY ATTEMPT

So far I have created .htaccess file in the www root content like this:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?mysite\.com$ [NC]

RewriteRule !^webFolder/subFolder1/subFolder/ /webFolder/subFolder1/subFolder%{REQUEST_URI} [L,NC]

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

And it work to redirect the www root, to the subFolder directory. But the problem is, the URL shown is stil http://mysite/webFolder/subFolder1/subFolder. And I also have put .htaccess file on servicesApi and anotherWebFolder folder to replace the URL, and it works.

Dedy Chaidir
  • 767
  • 6
  • 15

0 Answers0