Search code examples
.htaccesshttp-redirecturl-rewritingjoomla2.5subdirectory

Hide subdirectory urls with htaccess


I'm sure some way or another this question is as old as the method itself but my challenge was to make

site.eu/subfolder/subfolder appear as subdomain.site.eu

I managed to figure that out on my own and got it to work. The code is following:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain.site.eu [NC]
RewriteRule ^(.*)$ /subfolder1/subfolder2/%{REQUEST_URI} [R=301,P,NC]

The following issue is that in that adress, there is an app where you must log in.

After logging in, it will show subdomain.site.eu/subfolder1/subfolder2/content1

I have tried about 2-3 days to fix this but to no avail. I really hope somebody could help me out on this. IF there is any other info needed, please tell.


Solution

  • You can use this in root .htaccess:

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^subdomain\.site\.eu$ [NC]
    RewriteRule ^((?!subfolder1/subfolder2/).*)$ /subfolder1/subfolder2/%{REQUEST_URI} [L,NC]