0

I have a domain example.com, as well as some sub-domains sub1.example.com, sub2.example.com, ..etc. I want to load the main domain from a directory to organize the directories to avoid having Laravel project files and folders next to sub-domains folders.

public_html structure:

main
    app
    bootstrap
    ..
    public
    ..
sub1
    //Some files and directories
sub2
    //Some files and directories
.htaccess

.htaccess:

RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/main/ [NC]
RewriteRule ^(.*)$ /main/public/$1 [L]

This code will load files for example.com from example.com/main/public.

The issue is that when I leave the website opened in a browser tab for a while (maybe a couple of hours) and visit that tab, the URL becomes example.com/main/public. If I type example.com/main/public in the browser the website loads as well.

Is there a way to force it to load the website from example.com only?

2
  • The question is unclear. (wondering how this was passed the Staging Ground). This code will load files for example.com from example.com/main/public Okay URL becomes example.com/main/public It should because same page(Unless you have inactive catchers ). If I type example.com/main/public in the browser the website loads as well. ??? Commented Jul 4 at 12:56
  • @AbdullaNilam I don't want the URL to contain main/public. The website should be loaded from example.com only. Commented Jul 4 at 13:00

0

Browse other questions tagged or ask your own question.