Skip to content

Commit b816e9a

Browse files
committed
[WebApp] Add rewrite rule for /public folder to .htaccess file (Laravel and Symfony)
1 parent cf77f95 commit b816e9a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

web/src/app/WebApp/Installers/LaravelSetup.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,20 @@ class LaravelSetup extends BaseSetup {
1919
],
2020
];
2121

22+
public function install(array $options=null) : bool
23+
{
24+
parent::install($options);
25+
$result = null;
26+
27+
$htaccess_rewrite = '
28+
<IfModule mod_rewrite.c>
29+
RewriteEngine On
30+
RewriteRule ^(.*)$ public/$1 [L]
31+
</IfModule>';
32+
33+
$tmp_configpath = $this->saveTempFile($htaccess_rewrite);
34+
$this->appcontext->runUser('v-move-fs-file',[$tmp_configpath, $this->getDocRoot(".htaccess")], $result);
35+
36+
return ($result->code === 0);
37+
}
2238
}

web/src/app/WebApp/Installers/SymfonySetup.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,23 @@ class SymfonySetup extends BaseSetup {
1919
],
2020
];
2121

22+
public function install(array $options=null) : bool
23+
{
24+
parent::install($options);
25+
$result = null;
26+
27+
$htaccess_rewrite = '
28+
<IfModule mod_rewrite.c>
29+
RewriteEngine On
30+
RewriteRule ^(.*)$ public/$1 [L]
31+
</IfModule>';
32+
33+
$this->appcontext->runComposer(["config", "-d " . $this->getDocRoot(), "extra.symfony.allow-contrib", "true"], $result);
34+
$this->appcontext->runComposer(["require", "-d " . $this->getDocRoot(), "symfony/apache-pack"], $result);
35+
36+
$tmp_configpath = $this->saveTempFile($htaccess_rewrite);
37+
$this->appcontext->runUser('v-move-fs-file',[$tmp_configpath, $this->getDocRoot(".htaccess")], $result);
38+
39+
return ($result->code === 0);
40+
}
2241
}

0 commit comments

Comments
 (0)