Issue
-
When there are 2 or more sites for example Site1 and Site2.
Site1 is mapped to the friendly URL "site1" and Site2 is mapped to "site2".
They both have virtual hosts site1.com and site2.com. -
The sites can be reached through localhost:8080/web/site1 or localhost:8080/web/site2 as well as site1.com and site2.com.
-
Site1 can also be reached through site2.com/web/site1 and Site1 can be reached the same way on site2.com/web/site1.
Environment
- DXP 7.4
Resolution
-
To enforce access restrictions on websites accessed from virtual hosts divergent from their designated assignments, you can employ Apache's redirection capabilities.
Apache serves as a front-facing web server interfacing with Liferay's Tomcat infrastructure, facilitating the implementation of such access control measures. - This can also be achieved by utilizing Nginx rewrite rule functionality.
-
Please see the following example:
RewriteCond expr "! %{HTTP_REFERER} -strmatch '*://%{HTTP_HOST}/group/*'"
RewriteRule ^/web/group-key https://www.group-domain.com [R,L]