将我的路径转换为整个查询的规则


Rule to transform my path to an entire query

示例:

我在浏览器中访问:

www.example.com/documents/pages/doc.php?培根=烤的&this=tastes_good

我希望这个链接能访问这个页面,并将路径编码到查询中:

www.example.com/index.php?url=文档%2Fpages%2Fdoc.php%3Flank%3Baked%26this%3Tastes_good

问题是,这个index.php需要使用大的"url"查询变量在php中对其进行解码和修改,然后从其他网站fopen()所需的页面
我需要做所有这些,因为这两个网站需要使用相同的$_SESSION、数据库和文件,而且很难完全分离。

假设您的.htaccess位于web根目录/

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index'.php [NC]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ index.php?url=$1%3F%1 [B,NE,L]

如果仍然发现这些/未被编码为%2F,则可能必须在服务器的httpd.conf配置文件中启用AllowEncodedSlaches。