转换路径使用mod_rewrite查询字符串变量 [英] Convert path to query string variable using mod_rewrite
本文介绍了转换路径使用mod_rewrite查询字符串变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图让Apache派:结果 http://mydomain.com/these/are/arguments/mmmk
I am trying to make Apache send:
http://mydomain.com/these/are/arguments/mmmk
要:结果 http://mydomain.com/?pages=these/are/arguments/mmmk
这样 $ _ GET [页]
将显示这/是/参数/ mmmk
。
我已经设置'AllowEn codedSlashes为开。
I have set 'AllowEncodedSlashes' to On.
该规则需要能够处理尾随斜线,并且在没有子页面(如 http://mydomain.com
)
The rule needs to be able to handle trailing slashes, and when there is no subpages (like http://mydomain.com
)
有谁知道如何完成这个任务?
Does anyone know how to accomplish this task?
推荐答案
为了不改写图像/脚本,您需要确保文件或目录不.htaccess文件存在的第一个
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
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite everything else through the pages parameter
RewriteRule ^(.+)$ /?pages=$1 [L]
这篇关于转换路径使用mod_rewrite查询字符串变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文