MCPcopy Create free account
hub / github.com/apache/httpd / cmd_rewriterule

Function cmd_rewriterule

modules/mappers/mod_rewrite.c:3974–4080  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3972}
3973
3974static const char *cmd_rewriterule(cmd_parms *cmd, void *in_dconf,
3975 const char *in_str)
3976{
3977 rewrite_perdir_conf *dconf = in_dconf;
3978 char *str = apr_pstrdup(cmd->pool, in_str);
3979 rewrite_server_conf *sconf;
3980 rewriterule_entry *newrule;
3981 ap_regex_t *regexp;
3982 char *a1 = NULL, *a2 = NULL, *a2_end, *a3 = NULL;
3983 const char *err;
3984
3985 sconf = ap_get_module_config(cmd->server->module_config, &rewrite_module);
3986
3987 /* make a new entry in the internal rewrite rule list */
3988 if (cmd->path == NULL) { /* is server command */
3989 newrule = apr_array_push(sconf->rewriterules);
3990 }
3991 else { /* is per-directory command */
3992 newrule = apr_array_push(dconf->rewriterules);
3993 }
3994
3995 /* parse the argument line ourself */
3996 if (parseargline(str, &a1, &a2, &a2_end, &a3)) {
3997 return apr_pstrcat(cmd->pool, "RewriteRule: bad argument line '", str,
3998 "'", NULL);
3999 }
4000
4001 newrule->forced_mimetype = NULL;
4002 newrule->forced_handler = NULL;
4003 newrule->forced_responsecode = HTTP_MOVED_TEMPORARILY;
4004 newrule->flags = RULEFLAG_NONE;
4005 newrule->env = NULL;
4006 newrule->cookie = NULL;
4007 newrule->skip = 0;
4008 newrule->maxrounds = REWRITE_MAX_ROUNDS;
4009 newrule->escapes = newrule->noescapes = NULL;
4010
4011 /* arg3: optional flags field */
4012 if (a3 != NULL) {
4013 if ((err = cmd_parseflagfield(cmd->pool, newrule, a3,
4014 cmd_rewriterule_setflag)) != NULL) {
4015 return apr_pstrcat(cmd->pool, "RewriteRule: ", err, NULL);
4016 }
4017 }
4018
4019 /* arg1: the pattern
4020 * try to compile the regexp to test if is ok
4021 */
4022 if (*a1 == '!') {
4023 newrule->flags |= RULEFLAG_NOTMATCH;
4024 ++a1;
4025 }
4026
4027 regexp = ap_pregcomp(cmd->pool, a1, AP_REG_EXTENDED |
4028 ((newrule->flags & RULEFLAG_NOCASE)
4029 ? AP_REG_ICASE : 0));
4030 if (!regexp) {
4031 return apr_pstrcat(cmd->pool,

Callers

nothing calls this directly

Calls 5

ap_get_module_configFunction · 0.85
parsearglineFunction · 0.85
cmd_parseflagfieldFunction · 0.85
ap_pregcompFunction · 0.85
ap_strchrFunction · 0.85

Tested by

no test coverage detected