lighttpd 和 fastcgi.map-extension 检测/内容协商重写的“clean”没有文件扩展名的 URL?
我当前的网站使用 PHP 构建 HTML 内容并将其输出到重写的“干净”url 指定的浏览器。
url.rewrite-once = (
"^/([-a-zA-Z0-9]+)/$" => "/index.php?section=$1",
"^/([-a-zA-Z0-9/]+)/([-a-zA-Z0-9/]+)$" => "/index.php?section=$1&article=$2"
)
index.php 只是调用我的函数来根据变量构建和输出内容:
http://domain.com/some-section/this-is-an-article/
目前这只是平面 HTML 输出,但我现在希望在平面输出中包含 PHP,主要用于页面加载时的 PHP include 调用浏览器:
<h1>lorem ipsum</h1>
<?php include_once('example.php') ;?>
<p>Dolar sit amet.</p>
我只是认为我可以通过 php 映射 HTML:
fastcgi.map-extensions = ( ".html" => ".php" )
但是因为我的 URL 物理上没有文件扩展名,并且实际上也不存在任何带有扩展名的物理重写页面,所以 fastcgi 无法映射任何内容。
我已经测试过 fastcgi 通过简单地创建一个嵌入 PHP 的 .html 文件来工作,并且它被正确解析,所以我知道 .html 文件扩展名是通过 fastcgi 映射的。
我的问题很简单(或者不是),如果没有扩展名,如何让 fastcgi/lighttpd 通过 PHP 映射我的输出内容?
My current website uses PHP to build and output HTML content to the browser specified by rewritten "clean" urls.
url.rewrite-once = (
"^/([-a-zA-Z0-9]+)/$" => "/index.php?section=$1",
"^/([-a-zA-Z0-9/]+)/([-a-zA-Z0-9/]+)$" => "/index.php?section=$1&article=$2"
)
index.php simply calls my functions to build and output content depending on the variables:
http://domain.com/some-section/this-is-an-article/
At present this is just flat HTML output, but I am wanting to now in the flat output include PHP, mainly for PHP include calls when the page is loaded in the browser:
<h1>lorem ipsum</h1>
<?php include_once('example.php') ;?>
<p>Dolar sit amet.</p>
I simply thought I could map HTML through php as such:
fastcgi.map-extensions = ( ".html" => ".php" )
But because my URLs do not physically have file extensions and nor does any physical rewritten page with extension actually exist, fastcgi cannot map anything.
I have tested that fastcgi works by simply creating a .html file with embedded PHP and it is parsed correctly, so I know .html file extensions are being mapped through fastcgi.
My question is simply (or not so) how would one get fastcgi/lighttpd to map my outputted content through PHP if it does not have an extension?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论