Laravel projet hosted with Apache wirtuahost different port and subfolder

  .htaccess, apache, php, redirect, windows

I have a windows server (2012), with an Apache 2.4 hosting some php apps.
The default PHP version is a 7.2 version.

I want to host on it a Laravel project, using PHP 8.1.

So I specified a new virtualhost with a different port number.

But what I really want is this :

my-domain.example.com/my-laravel-project => redirect to my-domaine.example.com:8001

So I set up a ProxyPass and ProxyPassReverse.

But I can’t make it work.

I don’t have any other choice right now (no subdomain possible), no global upgrade to PHP8.1 (too risky).

This is the configuration :

 <VirtualHost *:80>
    ProxyPreserveHost On
    
    ProxyPass "/my-laravel-app" "http://127.0.0.1:8001/my-laravel-app"
    ProxyPassReverse "/my-laravel-app" "http://127.0.0.1:8001/my-laravel-app"

</VirtualHost>
<VirtualHost *:8001>

 DocumentRoot "E:/PHP8.1Projects/"

 Alias "/my-laravel-app" "E:/PHP8.1Projects/my-laravel-app/public"

 FcgidInitialEnv PHPRC "E:php8.1"

 <Files ~ ".php$"> 
  Options Indexes FollowSymLinks ExecCGI 
  AddHandler fcgid-script .php 
  FcgidWrapper "E:php8.1php-cgi.exe" .php 
 </Files>

 DirectoryIndex index.php
 AddDefaultCharset UTF-8
</VirtualHost>

I already spent hours, I tried multiple things but I always got a problem.

Thanks for any help

Source: Windows Questions

LEAVE A COMMENT