{"id":778,"date":"2016-08-09T00:06:03","date_gmt":"2016-08-08T18:36:03","guid":{"rendered":"http:\/\/www.middlewareprimer.com\/blog\/?p=778"},"modified":"2016-08-09T00:06:03","modified_gmt":"2016-08-08T18:36:03","slug":"webserver-rewriterule","status":"publish","type":"post","link":"http:\/\/www.middlewareprimer.com\/blog\/2016\/08\/09\/webserver-rewriterule\/","title":{"rendered":"Webserver RewriteRule"},"content":{"rendered":"<p>Webserver RewriteRule information given below for reference. As part of Apache documentation,<\/p>\n<p>The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch. mod_rewrite provides a flexible and powerful way to manipulate URLs using an unlimited number of rules. Each rule can have an unlimited number of attached rule conditions, to allow you to rewrite URL based on server variables, environment variables, HTTP headers, or time stamps.<\/p>\n<p>mod_rewrite operates on the full URL path, including the path-info section. A rewrite rule can be invoked in httpd.conf or in .htaccess. The path generated by a rewrite rule can include a query string, or can lead to internal sub-processing, external request redirection, or internal proxy throughput.<\/p>\n<p>Rewrite rule reference link from <a href=\"http:\/\/httpd.apache.org\/docs\/current\/mod\/mod_rewrite.html\" target=\"_blank\"><span style=\"text-decoration: underline;\"><strong>Apache documentation<\/strong><\/span><\/a><\/p>\n<p><strong>Syntax:<\/strong>\u00a0\u00a0 \u00a0<strong>RewriteRule Pattern Substitution [flags]<\/strong><\/p>\n<p>The <strong>RewriteRule<\/strong> directive is the real rewriting workhorse. The directive can occur more than once, with each instance defining a single rewrite rule. The order in which these rules are defined is important &#8211; this is the order in which they will be applied at run-time.<\/p>\n<p><strong>Pattern<\/strong> is a perl compatible regular expression. On the first RewriteRule, it is matched against the (%-decoded) URL-path of the request, or, in per-directory context (see below), the URL path relative to that per-directory context. Subsequent patterns are matched against the output of the last matching RewriteRule.<\/p>\n<p>The <strong>Substitution<\/strong> of a rewrite rule is the string that replaces the original URL-path that was matched by Pattern.<\/p>\n<p><strong> Flags<\/strong> is a comma-separated list, surround by square brackets, of any of the flags in the following image,<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-831\" src=\"http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/flags1.png\" alt=\"flags1\" width=\"1176\" height=\"533\" srcset=\"http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/flags1.png 1176w, http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/flags1-300x136.png 300w, http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/flags1-768x348.png 768w, http:\/\/www.middlewareprimer.com\/blog\/wp-content\/uploads\/2016\/08\/flags1-1024x464.png 1024w\" sizes=\"auto, (max-width: 1176px) 100vw, 1176px\" \/><\/p>\n<p>Some of the examples are mentioned in below link for reference. They give examples on how to use redirect rule in webserver.<\/p>\n<p><a href=\"http:\/\/httpd.apache.org\/docs\/2.0\/misc\/rewriteguide.html\" target=\"_blank\">http:\/\/httpd.apache.org\/docs\/2.0\/misc\/rewriteguide.html<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Webserver RewriteRule information given below for reference. As part of Apache documentation, The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[226,213,246],"class_list":["post-778","post","type-post","status-publish","format-standard","hentry","category-web-server","tag-http-server","tag-mod_rewrite","tag-rewriterule"],"_links":{"self":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/778","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/comments?post=778"}],"version-history":[{"count":5,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/778\/revisions"}],"predecessor-version":[{"id":832,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/posts\/778\/revisions\/832"}],"wp:attachment":[{"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/media?parent=778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/categories?post=778"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.middlewareprimer.com\/blog\/wp-json\/wp\/v2\/tags?post=778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}