Skip to content

Magento 2.4.6 in subfolder on Apache2

Ok, lets see if this famous issue got some updates and solutions. Seen many questions about it, but no real solutions.

I’m having a setup with two different systems in two subfolders, like this

root
    wordpress
    magento

Domain points to root, htaccess in root distributes the request to wordpress or magento. That part is doing fine so far, however every single request to Magento results in 404.

Magento base url is set to domain.com/magento and I had to alter the Magento root .htaccess to point to pub directory inside magento directory, otherwise requests are not targeting Magento at all.

RewriteCond %{REQUEST_URI} !^/pub/
RewriteCond %{REQUEST_URI} !^/setup/
RewriteCond %{REQUEST_URI} !^/update/
RewriteCond %{REQUEST_URI} !^/dev/
RewriteRule .* /magento/pub/$0 [L]
DirectoryIndex index.php

Any ideas how to set this up? Is Magento really that difficult it can’t be ran in subfolder?