{"id":414,"date":"2018-10-26T21:30:19","date_gmt":"2018-10-26T21:30:19","guid":{"rendered":"http:\/\/www.projectimmerse.com\/?p=414"},"modified":"2020-06-17T09:41:39","modified_gmt":"2020-06-17T09:41:39","slug":"wpengine-nginx-htaccess","status":"publish","type":"post","link":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/","title":{"rendered":"WPEngine, Nginx and htaccess"},"content":{"rendered":"<p>Redirects can get hairy sometimes &#8211; sometimes you get a nice clean canvas of directives, sometimes it&#8217;s messy and undocumented. Whatever the case, you&#8217;re dealing with an .htaccess file. One wrong move and you can crash your site<br \/>\nor worse yet a clients site. So before anything else make sure you have FTP access and you create a back up of their existing .htaccess file. Don&#8217;t even be tempted to do it through Yoast &#8211; even though they allow you to edit the .htaccess file right through WordPress. I&#8217;ve seen it happen and it isn&#8217;t worth it. <\/p>\n<p>So you&#8217;ve got the .htaccess file &#8211; you&#8217;re going down line by line. It can look like a jungle at times &#8211; you&#8217;ll see caching stuff, some 301 redirects, some permission stuff. <\/p>\n<p><!--more--><\/p>\n<p>With the task I got though, I simply had to redirect a .pdf file to an external domain. So you know how it goes, it could look something like this:<\/p>\n<p>This is the mod_rewrite version<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nRewriteEngine On\r\nRewriteBase \/\r\nRewriteCond %{REQUEST_URI} ^\/old\/path\/file.pdf$\r\nRewriteRule ^(.*) \/new\/path\/file.pdf &#x5B;L,R=301]\r\n\r\n<\/pre>\n<p>And the mod_alias version<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\r\nRedirect 301 \/old\/path\/file.pdf \/new\/path\/file.pdf\r\n\r\n<\/pre>\n<p>Use either one and you&#8217;re all good and gravy &#8211; not unless you&#8217;re using <a href=\"https:\/\/wpengine.com\" title=\"WPEngine\">WPEngine<\/a>. I like this service, I actually recommend this to people looking for a user friendly platform to work with when building a wordpress site for their business. <\/p>\n<p>So I was stumped for while &#8211; a long while actually. Why weren&#8217;t these directives working? Well come to find out after checking in with the guys and gals over there at WPEngine, that files were being served up and cached by <a href=\"https:\/\/www.nginx.com\/\" title=\"Nginx\">Nginx<\/a>. Nginx is another web server just like Apache. I don&#8217;t have much in depth knowledge of Nginx to be honest. <\/p>\n<p>Here&#8217;s the information the tech provided:<\/p>\n<blockquote>\n<p>Might be because static files are cached and served by nginx above apache. You should be able to use our redirect rules section in the user portal and that should work.<\/p>\n<\/blockquote>\n<p>Alright to redirect any file formatted url &#8211; .pdf, .html, .aspx, .doc, etc, redirects had to be added using WPEngine. <\/p>\n<p>Login in to your WPEngine account and through the dashboard, find &#8220;Redirect Rules&#8221; and here we can the necessary redirects.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.projectimmerse.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-26-at-2.25.33-PM.png\" alt=\"\" width=\"887\" height=\"369\" class=\"aligncenter size-full wp-image-416\" srcset=\"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-26-at-2.25.33-PM.png 887w, https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-26-at-2.25.33-PM-300x125.png 300w, https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-26-at-2.25.33-PM-768x319.png 768w, https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-26-at-2.25.33-PM-80x33.png 80w\" sizes=\"auto, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px\" \/> <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Redirects can get hairy sometimes &#8211; sometimes you get a nice clean canvas of directives, sometimes it&#8217;s messy and undocumented. Whatever the case, you&#8217;re dealing with an .htaccess file. One wrong move and you can crash your site or worse yet a clients site. So before anything else make sure you have FTP access and &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;WPEngine, Nginx and htaccess&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":1166,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-414","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WPEngine, Nginx and htaccess - 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\/wpengine-nginx-htaccess\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WPEngine, Nginx and htaccess - Project Immerse\" \/>\n<meta property=\"og:description\" content=\"Redirects can get hairy sometimes &#8211; sometimes you get a nice clean canvas of directives, sometimes it&#8217;s messy and undocumented. Whatever the case, you&#8217;re dealing with an .htaccess file. One wrong move and you can crash your site or worse yet a clients site. So before anything else make sure you have FTP access and &hellip; Continue reading &quot;WPEngine, Nginx and htaccess&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/\" \/>\n<meta property=\"og:site_name\" content=\"Project Immerse\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-26T21:30:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-17T09:41:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/wpengine-ngnix-htaccess-redirects.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=\"projectimmerse\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"projectimmerse\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/\"},\"author\":{\"name\":\"projectimmerse\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"headline\":\"WPEngine, Nginx and htaccess\",\"datePublished\":\"2018-10-26T21:30:19+00:00\",\"dateModified\":\"2020-06-17T09:41:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/\"},\"wordCount\":398,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/wpengine-ngnix-htaccess-redirects.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/\",\"name\":\"WPEngine, Nginx and htaccess - Project Immerse\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/wpengine-ngnix-htaccess-redirects.png\",\"datePublished\":\"2018-10-26T21:30:19+00:00\",\"dateModified\":\"2020-06-17T09:41:39+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/#\\\/schema\\\/person\\\/c53f2864be524ee6fa08a7e4800dd1e5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/wpengine-ngnix-htaccess-redirects.png\",\"contentUrl\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/10\\\/wpengine-ngnix-htaccess-redirects.png\",\"width\":750,\"height\":750,\"caption\":\"WPEngine, Nginx and htaccess\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/wpengine-nginx-htaccess\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WPEngine, Nginx and htaccess\"}]},{\"@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\":\"projectimmerse\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g\",\"caption\":\"projectimmerse\"},\"url\":\"https:\\\/\\\/www.projectimmerse.com\\\/blog\\\/author\\\/projectimmerse\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WPEngine, Nginx and htaccess - 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\/wpengine-nginx-htaccess\/","og_locale":"en_US","og_type":"article","og_title":"WPEngine, Nginx and htaccess - Project Immerse","og_description":"Redirects can get hairy sometimes &#8211; sometimes you get a nice clean canvas of directives, sometimes it&#8217;s messy and undocumented. Whatever the case, you&#8217;re dealing with an .htaccess file. One wrong move and you can crash your site or worse yet a clients site. So before anything else make sure you have FTP access and &hellip; Continue reading \"WPEngine, Nginx and htaccess\"","og_url":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/","og_site_name":"Project Immerse","article_published_time":"2018-10-26T21:30:19+00:00","article_modified_time":"2020-06-17T09:41:39+00:00","og_image":[{"width":750,"height":750,"url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/wpengine-ngnix-htaccess-redirects.png","type":"image\/png"}],"author":"projectimmerse","twitter_card":"summary_large_image","twitter_misc":{"Written by":"projectimmerse","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#article","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/"},"author":{"name":"projectimmerse","@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"headline":"WPEngine, Nginx and htaccess","datePublished":"2018-10-26T21:30:19+00:00","dateModified":"2020-06-17T09:41:39+00:00","mainEntityOfPage":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/"},"wordCount":398,"commentCount":0,"image":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/wpengine-ngnix-htaccess-redirects.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/","url":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/","name":"WPEngine, Nginx and htaccess - Project Immerse","isPartOf":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#primaryimage"},"image":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#primaryimage"},"thumbnailUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/wpengine-ngnix-htaccess-redirects.png","datePublished":"2018-10-26T21:30:19+00:00","dateModified":"2020-06-17T09:41:39+00:00","author":{"@id":"https:\/\/www.projectimmerse.com\/blog\/#\/schema\/person\/c53f2864be524ee6fa08a7e4800dd1e5"},"breadcrumb":{"@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#primaryimage","url":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/wpengine-ngnix-htaccess-redirects.png","contentUrl":"https:\/\/www.projectimmerse.com\/blog\/wp-content\/uploads\/2018\/10\/wpengine-ngnix-htaccess-redirects.png","width":750,"height":750,"caption":"WPEngine, Nginx and htaccess"},{"@type":"BreadcrumbList","@id":"https:\/\/www.projectimmerse.com\/blog\/wpengine-nginx-htaccess\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.projectimmerse.com\/blog\/"},{"@type":"ListItem","position":2,"name":"WPEngine, Nginx and htaccess"}]},{"@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":"projectimmerse","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4d06955033d6227bfdcf30014e457e4334f7deeb73907de49b65ec2484921931?s=96&d=mm&r=g","caption":"projectimmerse"},"url":"https:\/\/www.projectimmerse.com\/blog\/author\/projectimmerse\/"}]}},"_links":{"self":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/414","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=414"}],"version-history":[{"count":4,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/414\/revisions"}],"predecessor-version":[{"id":442,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/posts\/414\/revisions\/442"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/media\/1166"}],"wp:attachment":[{"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/media?parent=414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/categories?post=414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.projectimmerse.com\/blog\/wp-json\/wp\/v2\/tags?post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}