htaccess url masking mod rewrite instead of VirtualHost File

49 views Asked by At

I want to mask the URL of all the pages so that when accessing them:

  • https://example.com/folder1/folder2

  • https://example.com/folder1/folder2/browse

  • https://example.com/folder1/folder2/details

is displayed as:

  • https://example.com

  • https://example.com/browse

  • https://example.com/details

I only want to mask /folder1/folder2 of all the pages.

I have this on .htaccess but it only works for:

https://example.com/folder1/folder2

is displayed as:

https://example.com
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^https://example.com$
RewriteCond %{REQUEST_URI} !folder1/folder2/
RewriteRule (.*) /folder1/folder2/$1 [L]

Options SymLinksIfOwnerMatch
</IfModule>

Hope someone can help me

Edit.

There is another .htaccess which is located in folder2:

(The first .htaccess is located in the root folder)

RewriteEngine on
#RewriteBase /

# Do not process images or CSS files further
RewriteRule \.(css|jpe?g|gif|png|js|ico|mp3|ogg|woff?2)$ - [L]

# Leave /admin and /install static
RewriteRule ^(admin|install).*$ - [L]

# Rewrite web pages to one master page
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [B=\ ;,QSA,L]
RewriteRule ^([^/\.]+)/([^/]+)/?$ index.php?page=$1&id=$2 [B=\ ;,QSA,L]
RewriteRule ^([^/\.]+)/([^/]+)/([^/]+)/? index.php?page=$1&id=$2&subpage=$3 [B=\ ;,QSA,L]
0

There are 0 answers