{"id":1424,"date":"2012-09-14T13:10:35","date_gmt":"2012-09-14T05:10:35","guid":{"rendered":"http:\/\/rmohan.com\/?p=1424"},"modified":"2012-09-14T13:11:42","modified_gmt":"2012-09-14T05:11:42","slug":"rewrite-only-if-a-folder-exists","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1424","title":{"rendered":"Rewrite only if a folder exists"},"content":{"rendered":"<p><strong>RewriteCond<\/strong>that checks if the requested file exists:<\/p>\n<p><code>RewriteCond %{REQUEST_FILENAME} !-f<\/code><\/p>\n<p>Great, but that\u2019s not what I was looking for. Instead I needed to Rewrite only if a specific folder existed. The solution turns out to be this:<\/p>\n<p><code>RewriteCond %{DOCUMENT_ROOT}\/path\/within\/your\/project\/ -d<\/code><\/p>\n<p>You need DOCUMENT_ROOT as the RewriteCond -d checks for the full path<\/p>\n<p>&nbsp;<\/p>\n<blockquote>\n<p>&lt;IfModule mod_rewrite.c&gt;<\/p>\n<p>Options +FollowSymLinks<\/p>\n<p>RewriteEngine On<\/p>\n<p>RewriteBase \/<\/p>\n<p>RewriteRule ^index.php$ \u2013 [L]<\/p>\n<p>RewriteCond %{REQUEST_FILENAME}\u00a0!-f<\/p>\n<p>RewriteCond %{REQUEST_FILENAME}\u00a0!-d<\/p>\n<p>RewriteRule . \/index.php [L]<\/p>\n<p>&lt;\/IfModule&gt;<\/p>\n<\/blockquote>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>RewriteCondthat checks if the requested file exists:<\/p>\n<p>RewriteCond %{REQUEST_FILENAME} !-f<\/p>\n<p>Great, but that\u2019s not what I was looking for. Instead I needed to Rewrite only if a specific folder existed. The solution turns out to be this:<\/p>\n<p>RewriteCond %{DOCUMENT_ROOT}\/path\/within\/your\/project\/ -d<\/p>\n<p>You need DOCUMENT_ROOT as the RewriteCond -d checks for the full path<\/p>\n<p>&nbsp;<\/p>\n<p>&lt;IfModule mod_rewrite.c&gt;<\/p>\n<p> [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1424"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1424"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1424\/revisions"}],"predecessor-version":[{"id":1427,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1424\/revisions\/1427"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}