通过一个 php 文件处理任何页面的 http 请求



我想处理所有http://www.example.com/any/possible/subpage请求的方式是,它们仍然出现在请求浏览器中的完整URL下,但全部由一个php文件http://www.example.com/any/index.php回答(就像Zend Framework一样)。索引.php使用/possible/subpage路径来传递请求的内容。

我该怎么做?这仅仅是配置 .htacces 的问题吗?谢谢。

在 "any" 文件夹中,将其添加到 htAccess 文件中:

RewriteEngine On
RewriteCond $1 !index.php
RewriteRule ^(.*)$ index.php [L]

如果您需要将"可能/子页面"部分作为参数传入,则规则行需要如下所示:

RewriteRule ^(.*)$ index.php?url=$1 [L]

相关内容

最新更新