企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#Apache服务器URL重写 先看下Apache重写的参数 * ```R[=code](force redirect)```强制外部重定向.强制在替代字符串加上http://host[:port]/ 前缀重定向到外部的URL.如果code不指定,将用缺省的302 HTTP状态码。 * F(force URL to be forbidden)禁用URL,返回403HTTP状态码。 * G(force URL to be gone) 强制URL为GONE,返回410HTTP状态码。 * P(force proxy) 强制使用代理转发。 * L(last rule) 表明当前规则是最后一条规则,停止分析以后规则的重写。 * N(next round) 重新从第一条规则开始运行重写过程。 * C(chained with next rule) 与下一条规则关联 如果规则匹配则正常处理,该标志无效,如果不匹配,那么下面所有关联的规则都跳过。 * T=MIME-type(force MIME type) 强制MIME类型 * NS (used only if no internal sub-request) 只用于不是内部子请求 * NC(no case) 不区分大小写 * QSA(query string append) 追加请求字符串 * NE(no URI escaping of output) 不在输出转义特殊字符 * 例如:RewriteRule /foo/(.*) /bar?arg=P1=$1 [R,NE] 将能正确的将/foo/zoo 转换成/bar?arg=P1=zoo * PT(pass through to next handler) 传递给下一个处理, * 例如: RewriteRule ^/abc(.*) /def$1 [PT] # 将会交给/def规则处理 Alias /def /ghi * S=num(skip next rule(s)) 跳过num条规则 * E=VAR:VAL(set environment variable) 设置环境变量 ##使用文件夹下的.htaccess文件。 实用例子: 实现隐藏index.php Options +FollowSymlinks -Multiviews RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] 实现目录固定结尾的参数值跳转 如:匹配http://host/test/XXX_code 跳转 RewriteRule ^(.*)([_]?)code$ /test/index.php?s=$1$2code [QSA,PT,L]