{"id":5217,"date":"2017-04-08T15:27:56","date_gmt":"2017-04-08T19:27:56","guid":{"rendered":"http:\/\/www.dr-chuck.com\/csev-blog\/?p=5217"},"modified":"2017-04-08T15:27:56","modified_gmt":"2017-04-08T19:27:56","slug":"a-better-htaccess-for-silexsymfony-applications","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2017\/04\/a-better-htaccess-for-silexsymfony-applications\/","title":{"rendered":"A better .htaccess for Silex\/Symfony Applications"},"content":{"rendered":"<p>I am playing with Silex \/ Symfony for writing Tsugi applications and had to come up with a better .htaccess file because my old one did not route the &#8220;\/&#8221; into the fallback resource correctly. <\/p>\n<p>The problem is that there is a directory for &#8220;\/&#8221; that stops the final rewrite url from happening because of the (red) RewriteCond.<\/p>\n<p>So we add two very explicit rewrite statements (green) to handle the &#8220;standalone slash&#8221; and the &#8220;standalone slash followed by a query string&#8221;.<\/p>\n<pre>\r\n    &amp;lt;IfModule mod_rewrite.c&amp;gt;\r\n        RewriteEngine on\r\n        RewriteRule ^ - [E=protossl]\r\n        RewriteCond %{HTTPS} on\r\n        RewriteRule ^ - [E=protossl:s]\r\n\r\n<strong style=\"color:green;\">        # Root folder all alone\r\n        RewriteRule \"^\/$\" silex.php [L]\r\n        # Root folder with GET parameters\r\n        RewriteRule \"^\/?.*$\" silex.php [L]<\/strong>\r\n\r\n        RewriteRule \"(^|\/)\\.\" - [F]\r\n        RewriteCond %{REQUEST_FILENAME} !-f\r\n\r\n <span style=\"color:red\">       RewriteCond %{REQUEST_FILENAME} !-d<\/span>\r\n\r\n        RewriteCond %{REQUEST_URI} !=\/favicon.ico\r\n        RewriteRule ^ silex.php [L]\r\n    &amp;lt;\/IfModule&amp;gt;\r\n    &amp;lt;IfModule !mod_rewrite.c&amp;gt;\r\n        FallbackResource silex.php\r\n    &amp;lt;\/IfModule&amp;gt;\r\n<\/pre>\n<p>I have a feeling it won&#8217;t work well for the FallbackResource &#8211; as it will find the &#8220;.&#8221; folder and not &#8220;fall back&#8221;.  So this kind of means I need mod_rewrite.<\/p>\n<p>Alternatively just rename &#8216;silex.php&#8217; to &#8216;index.php&#8217; if I don&#8217;t want to have a separate index.php.<\/p>\n<p>Sigh.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am playing with Silex \/ Symfony for writing Tsugi applications and had to come up with a better .htaccess file because my old one did not route the &#8220;\/&#8221; into the fallback resource correctly. The problem is that there is a directory for &#8220;\/&#8221; that stops the final rewrite url from happening because of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5217","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/5217","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=5217"}],"version-history":[{"count":17,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/5217\/revisions"}],"predecessor-version":[{"id":5234,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/5217\/revisions\/5234"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=5217"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=5217"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=5217"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}