Server Fault Asked by luison on November 22, 2021
We are trying to migrate an installation to Apache event engine replacing mod_php for PHP-FPM.
We have a large an complex list of rewrites performed by apache from old urls and also to produce SEO friendly URLs as in:
#Ej: /holidays/costa-del-sol/nombre-99.html
RewriteRule ^/holidays/([^/])/([^/])-([d]+).html$ /scripts/pack.php?package=$3&lang=eng [QSA,P,E=notAllowedParams:package-region-regionname-lang,E=ORIG_URI:/$1]
But furthermore, our PHP also confirms that the clients used URL is valid and otherwise performs a redirect. For this, we evaluate the $SERVER REQUEST_URI variable, but this variable is now incorrectly set to the second "script" url instead of the source.
This is… Apache receives a request for URL X, rewrites (no 301) internally to a Y address. With mod_php that is transparent to PHP but now as we "proxy" to PHP-FM the Y script is called (so the rewrite is executed) but we can’t find a way to force REQUEST_URI value to be maintained and received by PHP.
Our Apache config for PHP-FPM
<FilesMatch .php$>
# 2.4.10+ can proxy to unix socket
# SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://localhost/"
# Else we can just use a tcp socket:
SetHandler "proxy:fcgi://127.0.0.1:9001"
</FilesMatch>
ProxyPassMatch ^/(..php(/.)?)$ fcgi://127.0.0.1:9001/${GIS_JOSE}/www/$1 enablereuse=on
We’ve tried various options to retain that value without success:
ProxyPreserveHost On
ProxyRequests Off
ProxyFCGISetEnvIf "true" REQUEST_URI "%{reqenv:REQUEST_URI}"
RewriteOptions InheritBefore
Our doubt is if it’s not possible or we are missing something regarding the order of execution.
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP