{"id":2200,"date":"2012-01-12T10:29:48","date_gmt":"2012-01-12T16:29:48","guid":{"rendered":"http:\/\/bililite.nfshost.com\/blog\/?p=2200"},"modified":"2012-01-12T10:29:48","modified_gmt":"2012-01-12T16:29:48","slug":"things-i-learned-about-htaccess-part-2","status":"publish","type":"post","link":"https:\/\/bililite.com\/blog\/2012\/01\/12\/things-i-learned-about-htaccess-part-2\/","title":{"rendered":"Things I Learned About .htaccess, part 2"},"content":{"rendered":"<p>I've <a href=\"\/blog\/2009\/07\/27\/things-i-learned-about-htaccess\/\">learned some things about .htaccess<\/a>, but mostly I've learned that programming it is deep black magic. The most important thing is \"Don't use mod-rewrite unless you absolutely need to\". All the fancy stuff is better off done by the PHP (or whatever language you're using) code.<\/p>\r\n<p>Don't do:<\/p>\r\n<pre><code>RewriteEngine On\r\nRewriteBase \/\r\nRewriteRule ^([^\/\\.]+)\/$ \/index.php?main=$1&part=$1 [QSA,L]\r\nRewriteRule ^([^\/\\.]+)\/([^\/\\.]+)$ \/index.php?main=$1&part=$2 [QSA,L]<\/code><\/pre>\r\n<p>to map your site to your index page; do:<\/p>\r\n<pre><code><a href=\"https:\/\/httpd.apache.org\/docs\/2.3\/mod\/mod_dir.html#fallbackresource\">FallbackResource<\/a> \/index.php<\/code><\/pre>\r\n<p>And in <code>index.php<\/code> parse the <code class=\"language-php\">$_SERVER['REQUEST_URI']<\/code> to get your page\/subpage arguments. Much easier to debug!<\/p>\r\n<p>And to use <code>FallbackResource<\/code> you need to be running Apache 2.2, so get a good web host.<\/p>","protected":false},"excerpt":{"rendered":"I've learned some things about .htaccess, but mostly I've learned that programming it is deep black magic. The most important thing is \"Don't use mod-rewrite unless you absolutely need to\". All the fancy stuff is better off done by the PHP (or whatever language you're using) code. Don't do: RewriteEngine On RewriteBase \/ RewriteRule ^([^\/\\.]+)\/$ [&hellip;]","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"_links":{"self":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2200"}],"collection":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/comments?post=2200"}],"version-history":[{"count":5,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2200\/revisions"}],"predecessor-version":[{"id":2205,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/posts\/2200\/revisions\/2205"}],"wp:attachment":[{"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/media?parent=2200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/categories?post=2200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bililite.com\/blog\/wp-json\/wp\/v2\/tags?post=2200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}