[英]Convert path to query string variable using mod_rewrite
I am trying to make Apache send: 我想让Apache发送:
http://mydomain.com/these/are/arguments/mmmk
to: 至:
http://mydomain.com/?pages=these/are/arguments/mmmk
Such that $_GET['pages']
will display these/are/arguments/mmmk
. 这样
$_GET['pages']
将显示these/are/arguments/mmmk
。
I have set 'AllowEncodedSlashes' to On. 我已将'AllowEncodedSlashes'设置为On。
The rule needs to be able to handle trailing slashes, and when there is no subpages (like http://mydomain.com
) 规则需要能够处理尾部斜杠,并且当没有子页面时(例如
http://mydomain.com
)
Does anyone know how to accomplish this task? 有谁知道如何完成这项任务?
In order to not rewrite images/scripts you'll need to make sure the file or directory does not exist first in your .htaccess file 为了不重写图像/脚本,您需要确保.htaccess文件中的文件或目录不存在
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite everything else through the pages parameter
RewriteRule ^(.+)$ /?pages=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.