1
votes

I am using Apache 2 on Xubuntu to run multiple local instances of TYPO3. Since they use different TYPO3 and therefore PHP versions, I'm using fastcgi to pass requests to the one with TYPO3 version 9.5.x to the corresponding php7.2-fpm.

However, none of the pages other than "Home", the TYPO3 backend and the phpinfo are loading. I just get a raw 404 message which looks like it's coming from apache rather than from TYPO3 itself.

The only way I can get the pages to load is when I call them using the pageID and a parameter to suppress the redirect to the "more beautiful" URL. This, and the raw error page, make me believe that the problem lies within my Apache config rather than my TYPO3 setup. It seems like every call to a specific file (/index.php, /typo3/index.php, and /info.php) works, but the routing doesn't work because the apache tries to resolve it directly to a file/directory.

This is my apache config for the problematic vhost:

<VirtualHost *:80>
   ServerName test.test
   DocumentRoot /var/www/foo/bar/httpdocs

#    <FilesMatch \.php$>
#        SetHandler "proxy:unix:/var/run/php/php7.2-fpm.sock|fcgi://localhost"
#    </FilesMatch>

   ProxyPassMatch ^/(.*\.php(/.*)?)$ unix:/run/php/php7.2-fpm.sock|fcgi://localhost/var/www/foo/bar/httpdocs

   ErrorLog ${APACHE_LOG_DIR}/error.log
   CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

The commented part was the first try, when I noticed the problems I found the "ProxyPassMatch"-Part online and tried it out, but I have the same issues.

1
Do you have the .htaccess of TYPO3 in your TYPO3 document root? TYPO3 ships with a appropriate .htaccess which has the necessary rewrite rules for speaking URLs.Peter Kraume
@PeterKraume Yes I have, and I didn't change anything there.Florian M
Maybe you need to add RewriteBase /?Peter Kraume
@PeterKraume Where would I need to add that?Florian M
In your .htaccess file right after RewriteEngine on.Peter Kraume

1 Answers

0
votes

This is the crucial part of the rewriting in the default .htaccess (that is shipped with TYPO3):

<IfModule mod_rewrite.c>
    RewriteEngine On

    # ...         

    # If the file/symlink/directory does not exist => Redirect to index.php.
    # For httpd.conf, you need to prefix each '%{REQUEST_FILENAME}' with '%{DOCUMENT_ROOT}'.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]
</IfModule>

Important is that all URLs that are not file requests are passed on to index.php

First, check the obvious:

  1. Is mod_write enabled (e.g. a2enmod rewrite)?
  2. Is the .htaccess executed? As mentioned, in the comments, AllowOverride must be set.

For example, within the VirtualHost section, put this:

<Directory /var/www/foo/bar/httpdocs>
   # When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files.
   AllowOverride All
</Directory>

If that does not solve the problem, you can try narrowing down the problem step by step:

For example create a file /abc.txt with text "hello" in your web root. Then, add this before the TYPO3 rewrite blocks.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule /?xyz /abc.txt [L]
</IfModule>

Test the URLs /abc.txt, /xyz. They should both show "hello".

This way you can check if the rewrites work in general (without involving TYPO3). Once the test is successfull, remove again.

see also Troubleshooting in the Installation Guide, which also mentions the mod_rewrite.

Disclaimer: I don't know about the ProxyPassMatch but it seems to be generally working from what you described.