Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Komayo's avatar

.htaccess + subdirectory issues

Hi my friends, I will try to explain my issue in the best way i can.

My main domain points to a structure like this. (www.armada-lusitana.org - LIVE)

    *Root/www
        forum
        project1
        project2
        laravel
        entry

Entry is where i have the "public" directory of laravel, because i dont want its contents to mess with forum, project1, project2, and others directories, some of them of several other domains. "laravel" its the laravel content, packages, views, etc...

When i access www.armada-lusitana.org, it goes to http://armada-lusitana.org/entry/, all is working so far... *My objective is to hide the "/entry/" from url...

*My attempt via ".htaccess" (Root/www)

    <IfModule mod_rewrite.c> 
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^(www.)?armada-lusitana.org$
        RewriteCond %{REQUEST_URI} !^/entry/
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /entry/
        RewriteCond %{HTTP_HOST} ^(www.)?armada-lusitana.org$ 
        RewriteRule ^(/)?$ entry/index.php [L]
    </IfModule>

*".htaccess" (Root/www/entry) - default laravel .htaccess

    <IfModule mod_rewrite.c>
            <IfModule mod_negotiation.c>
                Options -MultiViews
            </IfModule>
        RewriteEngine On
            # Redirect Trailing Slashes...
            RewriteRule ^(.*)/$ / [L,R=301]
            # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
    </IfModule>

Now the issue, After this changes, after some searches on google, i should have the "entry" hidden from url, but its not. But this happens only when i open the website www.armada-lusitana.org or armada-lusitana.org, because it redirects or goes to www.armada-lusitana.org/entry/... If i directly delete the "/entry/" from the url, and clicke the buttons etc, it works good, and removes the "entry" from the url...

What iam missing here, my knowledge about .htaccess is not very good, so iam limited to copy pastes from google and alter them... maybe i need something more.

Thank you for your time to read, and for the help.

0 likes
15 replies
Komayo's avatar

Iam aware of the CSS files path issues with the changes...

wells's avatar

To simplify your setup, I would suggest first making the "entry" folder the root of your site and create symlinks to the other folders.

Komayo's avatar

What do you mean? Put the entry content on the root? That way i will have css, images, js, folders messing/mixture with the subdomains folders. What are symlinks?

wells's avatar

No need to move your content around. Simply edit your Apache config file to point the root folder to the entry folder.

Symlinks are essentially pointers to other folders located outside of the current folder. For example, you could store your laravel folder in /srv/www/laravel and create a symlink at /var/www/laravel that points to /srv/www/laravel/public

Komayo's avatar

Actualy i cant do that, because the domain, is the primary one of the hosting plan. So document_root is public_html. Only way to do it, is to make it as sub domain, not intended. So i realy need to stick with the htaccess solution... Any more solutions or tips?

bashy's avatar

You can still do that?

Symlink /public_html/laravel -> ../laravel/public

Komayo's avatar

Where i do that @bashy? My case would be maybe Symlink /public_html/ -> ../entry?????

bashy's avatar

@Komayo Oh you've pulled out entry from laravel folder which was named public?

If you want a sub directory to be Laravel (removing /public from URL), you need to symlink the sub directory you want to the laravel public folder.

  • Desired URL: example.com/laravel
  • DocumentRoot: /home/web/public_html

Symlink /home/web/public_html/laravelfiles/public -> /home/web/public_html/laravel

ln -s /home/web/public_html/laravelfiles/public /home/web/public_html/laravel
bashy's avatar

Did you manage to do it? I can't really work out what you've done or trying to do...

Komayo's avatar

@bashy if you dont mind, thank you for all your help and tips. Let me try to give you idea this way.

Follow these steps: 1. Enter here www.armada-lusitana.org. Result: New URL - http://armada-lusitana.org/entry/ (Because main domain is working in a subdirectory called "entry") 2. Click "About us". Result: http://armada-lusitana.org/entry/aboutus (Check URL with "entry") 3. At Address bar delete everything till "/entry/....." and hit ENTER Result: http://armada-lusitana.org/ 4. Click "About us". Result: http://armada-lusitana.org/aboutus (Check URL (PRETENDED ONE) without "entry")

My objective is to have this url everytime, but for some reason is not hiding "entry" when we enter the address first time, if we edit it, it works as its supose too. Seems some trouble with .htaccess file... I just cant figure out if its from the one at root of the hosting, or the one at entry/public folder.

Komayo's avatar

Seens the issue is fixed... maybe was the server delay to handle the .htaccess....dont know.... Anyway thank you for all your time and effort to help me, and the others too.

Thank you. @bashy @wells

bashy's avatar

Redirects are cached, yes. You should test it on something like cURL so you can see the response where no cache is used :)

Nice site anyway, I do a bit of gaming/community owner myself.

Please or to participate in this conversation.