sulu-docs
sulu-docs copied to clipboard
Running sulu in a subfolder
For changing only the admin url have an look at:
https://github.com/sulu/sulu-demo/pull/60/files
For having all in a subfolder:
Currently if you want to run sulu in a subfolder you need to touch the following files:
public/index.php
-if (preg_match('/^\/admin(\/|$)/', $_SERVER['REQUEST_URI'])) {
+if (preg_match('/^\/subfolder\/admin(\/|$)/', $_SERVER['REQUEST_URI'])) {
config/packages/framework_admin.yaml
This file need to be created:
framework:
session:
cookie_path: /subfolder/admin
fragments:
path: /subfolder/admin
config/packages/sulu_media.yaml
sulu_media:
routing:
media_proxy_path: '/subfolder/uploads/media/{slug}'
media_download_path: '/subfolder/media/{id}/download/{slug}'
config/webspaces/example.xml
<url language="en">{host}/subfolder</url>
The following is maybe optional
If symfony detects the subfolder configuration correctly the following is not needed this could e.g. happen if $_SERVER['PHP_SELF'] and $_SERVER['SCRIPT_NAME'] is set correctly:
$_SERVER['PHP_SELF']; // should be something like '/subfolder/index.php'
$_SERVER['SCRIPT_NAME']; // should be something like '/subfolder'
Else you need to change the configuration of all routes:
config/packages/security_admin.yaml
Add prefix to ALL
security urls:
- - { path: ^/admin/reset, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+ - { path: ^/subfolder/admin/reset, roles: IS_AUTHENTICATED_ANONYMOUSLY }
...
config/packages/fos_rest.yaml
fos_rest:
zone:
- - { path: ^/admin/* }
+ - { path: ^/subfolder/admin/* }
config/routes/*
Add /subfolder
to all urls all urls and add prefix: /subfolder to all imports.
Use following commands to debug:
bin/adminconsole debug:router
bin/websiteconsole debug:router
config/packages/media.yaml
Media routes are configured also in the following config:
sulu_media:
routing:
media_proxy_path: '/subfolder/uploads/media/{slug}'
media_download_path: '/subfolder/media/{id}/download/{slug}'
Vhost
Based on your webserver you need configure that the path-to-your-project/public
is running under /subfolder
.