I have this fodler structure:
Path to my laravel project:
/home/name/workspace/myProject
Path to my intermediary indexes:
/home/name/workspace/indexes/indexOne
/home/name/workspace/indexes/indexTwo
The two folders, indexOne and index Two contain a .env file and public fodler woth a index.php and a .haccess file.
I want my apache2 virtual host to point to one of my intermediary indexes public folder and use the env in that configuration.
If I make my virtual host to point to the /home/name/workspace/myProject/public it works but this is not what I need as that is the normal configuration.
My Virtual host config.
<VirtualHost *:8002>
ServerName dev-myApp.be
ServerAdmin webmaster@localhost
DocumentRoot /home/name/workspace/indexes/indexOne/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/home/name/workspace/indexes/indexOne/public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
This is my index.php from /home/name/workspace/indexes/indexOne/public:
<?php
// Redirect to the main index.php file in the project's public folder
$redirectTo = '/home/name/workspace/myProject/public/';
if (strpos($_SERVER['REQUEST_URI'], $redirectTo) === false) {
header('Location: ' . $redirectTo);
exit;
}
?>
This is my .htaccess file from /home/name/workspace/indexes/indexOne/public
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I get different errors depending on the config I try from 404 to to many redirects to the respoins beeing the content of the index.php file.