{"id":50,"date":"2018-07-11T22:31:22","date_gmt":"2018-07-11T22:31:22","guid":{"rendered":"http:\/\/www.projectimmerse.com\/?p=50"},"modified":"2020-06-16T23:08:18","modified_gmt":"2020-06-16T23:08:18","slug":"301-redirect-vs-301-redirectmatch","status":"publish","type":"post","link":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/","title":{"rendered":"301 Redirect vs 301 RedirectMatch"},"content":{"rendered":"<p>I was recently tasked with redirecting a url, pretty straightforward I thought. <\/p>\n<p>I said that was easy. But the issue was the trailing slash &#8211; this character had to be optional. <\/p>\n<p>In your .htaccess file&#8230;<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nRedirect 301 \/page-1\/ \/page-2\/\r\n\r\n<\/pre>\n<p><!--more--><\/p>\n<p>Introducing RedirectMatch. With RedirectMatch, we can utilize regular expressions to capture a trailing slash or non-trailing slash scenario. <\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nRedirectMatch 301 (?i)\/page\/?$ https:\/\/site.com\/page\/\r\n\r\n<\/pre>\n<p>The question mark &#8220;?&#8221; here means, &#8220;hey I&#8217;m optional&#8221;. In this case, the url can be both case insensitive followed by a trailing slash (or a non trailing slash).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was recently tasked with redirecting a url, pretty straightforward I thought. I said that was easy. But the issue was the trailing slash &#8211; this character had to be optional. In your .htaccess file&#8230; Redirect 301 \/page-1\/ \/page-2\/<\/p>\n","protected":false},"author":1,"featured_media":1114,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[57],"tags":[],"class_list":["post-50","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>301 Redirect vs 301 RedirectMatch - Project Immerse<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"301 Redirect vs 301 RedirectMatch - Project Immerse\" \/>\n<meta property=\"og:description\" content=\"I was recently tasked with redirecting a url, pretty straightforward I thought. I said that was easy. But the issue was the trailing slash &#8211; this character had to be optional. In your .htaccess file&#8230; Redirect 301 \/page-1\/ \/page-2\/\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/\" \/>\n<meta property=\"og:site_name\" content=\"Project Immerse\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-11T22:31:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-16T23:08:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/07\/301-redirect-vs-301-redirectmatch-using-htaccess.png\" \/>\n\t<meta property=\"og:image:width\" content=\"750\" \/>\n\t<meta property=\"og:image:height\" content=\"750\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Alex Mercer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alex Mercer\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/\"},\"author\":{\"name\":\"Alex Mercer\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"headline\":\"301 Redirect vs 301 RedirectMatch\",\"datePublished\":\"2018-07-11T22:31:22+00:00\",\"dateModified\":\"2020-06-16T23:08:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/\"},\"wordCount\":99,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/301-redirect-vs-301-redirectmatch-using-htaccess.png\",\"articleSection\":[\"Web Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/\",\"name\":\"301 Redirect vs 301 RedirectMatch - Project Immerse\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/301-redirect-vs-301-redirectmatch-using-htaccess.png\",\"datePublished\":\"2018-07-11T22:31:22+00:00\",\"dateModified\":\"2020-06-16T23:08:18+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/301-redirect-vs-301-redirectmatch-using-htaccess.png\",\"contentUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/301-redirect-vs-301-redirectmatch-using-htaccess.png\",\"width\":750,\"height\":750,\"caption\":\"301 Redirect vs 301 RedirectMatch using .htaccess\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/301-redirect-vs-301-redirectmatch\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"301 Redirect vs 301 RedirectMatch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/\",\"name\":\"Project Immerse\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\",\"name\":\"Alex Mercer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/alex-mercer-author-150x150.png\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/alex-mercer-author-150x150.png\",\"contentUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/alex-mercer-author-150x150.png\",\"caption\":\"Alex Mercer\"},\"description\":\"Alex Mercer is a writer and contributor at Project Immerse, covering web design, WordPress, web development, SEO, digital strategy, emerging technology, and the evolving world of the web. His work focuses on practical ideas, useful tools, and approachable guidance that help creators, developers, and business owners build better digital experiences. Alex writes with a hands-on, curiosity-driven approach, exploring both established web practices and new technologies shaping how websites are designed, built, and discovered.\",\"sameAs\":[\"https:\\\/\\\/www.projectimmerse.com\"],\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/author\\\/projectimmerse\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"301 Redirect vs 301 RedirectMatch - Project Immerse","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/","og_locale":"en_US","og_type":"article","og_title":"301 Redirect vs 301 RedirectMatch - Project Immerse","og_description":"I was recently tasked with redirecting a url, pretty straightforward I thought. I said that was easy. But the issue was the trailing slash &#8211; this character had to be optional. In your .htaccess file&#8230; Redirect 301 \/page-1\/ \/page-2\/","og_url":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/","og_site_name":"Project Immerse","article_published_time":"2018-07-11T22:31:22+00:00","article_modified_time":"2020-06-16T23:08:18+00:00","og_image":[{"width":750,"height":750,"url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/07\/301-redirect-vs-301-redirectmatch-using-htaccess.png","type":"image\/png"}],"author":"Alex Mercer","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Alex Mercer"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#article","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/"},"author":{"name":"Alex Mercer","@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"headline":"301 Redirect vs 301 RedirectMatch","datePublished":"2018-07-11T22:31:22+00:00","dateModified":"2020-06-16T23:08:18+00:00","mainEntityOfPage":{"@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/"},"wordCount":99,"commentCount":0,"image":{"@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#primaryimage"},"thumbnailUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/07\/301-redirect-vs-301-redirectmatch-using-htaccess.png","articleSection":["Web Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/","url":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/","name":"301 Redirect vs 301 RedirectMatch - Project Immerse","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#primaryimage"},"image":{"@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#primaryimage"},"thumbnailUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/07\/301-redirect-vs-301-redirectmatch-using-htaccess.png","datePublished":"2018-07-11T22:31:22+00:00","dateModified":"2020-06-16T23:08:18+00:00","author":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"breadcrumb":{"@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#primaryimage","url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/07\/301-redirect-vs-301-redirectmatch-using-htaccess.png","contentUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/07\/301-redirect-vs-301-redirectmatch-using-htaccess.png","width":750,"height":750,"caption":"301 Redirect vs 301 RedirectMatch using .htaccess"},{"@type":"BreadcrumbList","@id":"https:\/\/www.projectimmerse.com\/blog\/301-redirect-vs-301-redirectmatch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.projectimmerse.com\/blog\/"},{"@type":"ListItem","position":2,"name":"301 Redirect vs 301 RedirectMatch"}]},{"@type":"WebSite","@id":"https:\/\/www.projectimmerse.com\/blog\/#website","url":"https:\/\/www.projectimmerse.com\/blog\/","name":"Project Immerse","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.projectimmerse.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5","name":"Alex Mercer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2026\/09\/alex-mercer-author-150x150.png","url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2026\/09\/alex-mercer-author-150x150.png","contentUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2026\/09\/alex-mercer-author-150x150.png","caption":"Alex Mercer"},"description":"Alex Mercer is a writer and contributor at Project Immerse, covering web design, WordPress, web development, SEO, digital strategy, emerging technology, and the evolving world of the web. His work focuses on practical ideas, useful tools, and approachable guidance that help creators, developers, and business owners build better digital experiences. Alex writes with a hands-on, curiosity-driven approach, exploring both established web practices and new technologies shaping how websites are designed, built, and discovered.","sameAs":["https:\/\/www.projectimmerse.com"],"url":"https:\/\/www.projectimmerse.com\/blog\/author\/projectimmerse\/"}]}},"_links":{"self":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/50","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/comments?post=50"}],"version-history":[{"count":3,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/50\/revisions"}],"predecessor-version":[{"id":473,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/50\/revisions\/473"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/media\/1114"}],"wp:attachment":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/media?parent=50"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/categories?post=50"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/tags?post=50"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}