# Redirect Trailing Slashes If Not A Folder...
This explains how to setup a new project with Gentics Portal | essentials.
There are two different project types that can be used. Both of them are usable at the same time, but a project can only have one mode.
Folder mode In this mode projects are accessible from subfolders. For example: http://my-projects.com/project1/ and http://my-projects.com/project2/
The domain used here does not take into account the terms of configuration (so any domain can point to a project in folder mode, which does not point to any project in domain mode).
In that case, the top level folder is served from the __default__
project folder.
Domain mode In this mode projects are accessible from domains. Eg.: http://my-project1.com/ and http://my-project2.com/
All files are served from the project’s public folder. To activate the domain mode the included vhost.conf.example
must be renamed to vhost.conf
On VirtualHost file changes, the portal needs to be restarted with docker-compose restart portal
Copy the demo project as a new folder in the
projects/
folder, e.g.: as newproject
Screenshot
Adapt the
config/portal.php
inside this project see: Configuration Screenshots
Create a new node in the CMS (easiest way is to copy the Demo Project)
Screenshots
Change publish path and preview url.
Screenshot
portal.php
'projectName'
(spaces are converted to _ automatically)
Change your views / graphql files
Enable publishing by unchecking Aktualisierung deaktivieren
Screenshot
Publish the new node
Right click > "Frame neu laden" > to see progress of publishing
Screenshots
Brief check if project is online and working
Modify homepage and look at it in the Live URL Preview – if you are redirected to the login page, you need to change permissions
In the CMS rightclick on the node and select object properties
In field roles you can set which user group can see the folder’s contents (anonymous: guests, reference_role: logged in users)
Screenshots
Alternatively you can set permissions temporarily in the Mesh UI:
Open: http://localhost:8081/
Login as user: admin
, password: admin
Change to admin view (right top corner)
Screenshot
Go to permissions and check the Nodes of the roles reference_role (logged in users) and anonymous (guests):
Screenshot
reference_role
(the view for logged in users) Screenshot
anonymous
(the view for guests) Screenshot
Copy the demo project as a new folder in the projects/
folder, e.g.: as newproject
Adapt the
config/portal.php
inside this project see: Configuration Screenshots
Create a new node in the CMS (easiest way is to copy the Demo Project)
Change publish path to
/
and remove project name from preview url and add domain name and remove "demo" prefix from Mesh preview url and replace portal with your domain (e.g.: demo.localhost.gentics.com) Screenshot
portal.php
'projectName'
(spaces are converted to _ automatically)
Change your views / graphql files
Enable publishing by unchecking Aktualisierung deaktivieren
Screenshot
Publish the new node
Copy vhost.conf.example
to vhost.conf
and adapt if needed (project name must be the same name as the folder of the project, ServerName must be your domain)
Add your alias for the domain to the docker-compose.override.yaml file (demo.localhost.gentics.com)
Restart portal: docker-compose up -d
Info: If you are trying our demo.localhost.gentics.com example, you need to docker-compose restart portal
Brief check if project is online and working
Modify homepage and look at it in the Live URL Preview – if you are redirected to the login page, you need to change permissions
In the CMS rightclick on the node and select object properties
In field roles you can set which user group can see the folder’s contents (anonymous: guests, reference_role: logged in users)
Screenshots
Alternatively you can set permissions temporarily in the Mesh UI (description above in the folder mode example)
If you run into issues, please check the Troubleshooting page.
POST requests from the Gentics CMS to the CmsController do not work by default because the stock Laravel .htaccess redirects all requests that have a trailing slash in order to remove it. However due do the RFC standard which disallows POST redirects without user interaction, this means that the POST data is lost.
We can fix this easily, in portal/public/.htaccess
find this line (line 12):
# Redirect Trailing Slashes If Not A Folder...
Add this after:
RewriteCond %{REQUEST_METHOD} =GET
Create a file named as folders.*.conf - where * can be any string - in the projects/
folder, and the configuration will be loaded for all folder mode projects, so seperating between the projects need to be done in this configuration.
You can use however the environment variables to detect the current project, with mod_setenvif.
Available environment variables:
GPPHP_BLADE_MODE
- It can be domain
or folder
GPPHP_BLADE_PROJECT
- The name of the project coming from the folder name
GPPHP_REQUEST_URI
- The url relative to the project folder
Create a .htpasswd file in the projects/
folder and add user credentials to it. Tip: You can use online tools to create your .htpasswd file.
Create a folders.auth.conf in the projects/
folder and add the following content:
<Location />
# Require authentication in demo project for /example sub-path
SetEnvIfExpr "env('GPPHP_BLADE_PROJECT') == 'demo' && tolower(env('GPPHP_REQUEST_URI')) =~ m#^/example(/|$)#" require_auth=true
AuthUserFile /portal/projects/.htpasswd
AuthName "Authorized Users Only."
AuthType Basic
Order Deny,Allow
Deny from all
Satisfy any
Require valid-user
Allow from env=!require_auth
</Location>
Using this, in the demo project, the /example
sub-path will require authentication, and accepts credentials from the .htpasswd file.
If you want to protect your whole campaign remove && tolower(env('GPPHP_REQUEST_URI')
from the example above.
In this case, you have to additionally change your node properties in the CMS: add user:password@
after https://
to your Mesh Preview URL. Example: https://user:password@site.wko.at/campaign/api/preview/
if you have multiple projects in folder mode and you would like to protect some of them, add the following content to your folders.auth.conf in the projects/
folder
<Location ~ "(project1|project2)">
# Require authentication in project
SetEnvIfExpr "env('GPPHP_BLADE_PROJECT') == 'project1'" require_auth=true
SetEnvIfExpr "env('GPPHP_BLADE_PROJECT') == 'project2'" require_auth=true
# use common username/password
AuthUserFile /portal/projects/.htpasswd
AuthName "Authorized Users Only."
AuthType Basic
Order Deny,Allow
Deny from all
Satisfy any
Require valid-user
Allow from env=!require_auth
</Location>
Create a file named as project.*.conf - where * can be any string - in the projects' folder, eg.: projects/myproject
folder, and the configuration will be loaded for that domain mode project.
Create a .htpasswd file in the projects/
folder and add user credentials to it.
Create a project.auth.conf in the projects/myproject
folder and add the following content:
# Require authentication for /example sub-path
<Location "/example">
AuthName "Authorized Users Only."
AuthType Basic
AuthUserFile /portal/projects/.htpasswd
Require valid-user
</Location>
Using this, in a domain mode project, the /example
sub-path will require authentication, and accepts credentials from the .htpasswd file.
If you want to protect your whole campaign remove the subfolder name in the Location tag in the example above, like so: <Location "/">
In this case, you have to additionally change your node properties in the CMS: add user:password@
after https://
to your Mesh Preview URL. Example: https://user:password@yourdomain.com/api/preview/
An important note: If you have no freely accessible campaigns to check, add a dummy project for the kubernetes healthpoint check.
Copy the file docker-compose.override.yml.example
to docker-compose.override.yml
You can configure passwords, ports, environment variables and other settings in docker-compose.override.yml
The license key for the cms has to be changed.
See: Run the application