pub fn mount_php(
extensions: &mut Extensions,
connection: Connection,
capture_fn: impl Fn(&FatRequest, &Host) -> bool + Send + Sync + 'static,
path_rewrite: Option<impl Fn(&str, &FatRequest, &Host) -> CompactString + Send + Sync + 'static>,
)
Available on crate feature
php
only.Expand description
Redirects all requests where capture_fn
returns true to connection
.
Consider using mount_php_with_working_directory
for a simpler install. It allows you to
easily add PHP for a path on your server, pointing to an arbitrary working directory.
Priority is -8
.
A good capture_fn
is |req, _host| req.uri().path().ends_with(".php")
.
Setting
capture_fn
to|req, _host| req.uri().path() == "/sitemap.xml" || req.uri().path().ends_with(".php")
can be useful if you’re running WordPress.
If you set path_rewrite
, keep in mind that the path given to you is percent decoded (%20 -> ’ ’), so if
you’re taking the path from the request URI, make sure to percent decode the path again.