<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

      <title>Comments on: Hardcore Apache question: How to have an .htaccess file pull from WordPress?</title>
      <link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress/</link>
      <description>Comments on Ask MetaFilter post Hardcore Apache question: How to have an .htaccess file pull from WordPress?</description>
	  	  <pubDate>Mon, 24 Jul 2006 20:21:53 -0800</pubDate>
      <lastBuildDate>Mon, 24 Jul 2006 20:21:53 -0800</lastBuildDate>
      <language>en-us</language>
	  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
	  <ttl>60</ttl>

<item>
  	<title>Question: Hardcore Apache question: How to have an .htaccess file pull from WordPress?</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress</link>	
  	<description>Hardcore Apache question: How can I write an .htaccess file that will apply a RewriteRule to only the most recent file posted to my Wordpress blog? &lt;br /&gt;&lt;br /&gt; I post a video a day on my site, and I need to redirect the traffic to the most recent video to libsyn, which is set up for the traffic patterns caused by podcasts -- otherwise, my server runs sluggishly for a few hours every morning. The WordPress posts are written using a custom field which contains the URL of the video file to be posted, and I can hack WordPress to output a file containing only this URL. How can I write an .htaccess file that will compare the request string to the contents of this file, so that the URL of the most recent video will be automatically overwritten?&lt;br&gt;
&lt;br&gt;
Note that I&apos;m not extremely conversant with the details of Apache configuration -- I&apos;ve modified the regexps of a few RewriteRules that a friend wrote for me, but that&apos;s about it -- so the fuller the code sample, the better. Barring that, I&apos;m a quick study, so a link to a syntax reference would do me fine as well.&lt;br&gt;
&lt;br&gt;
Thanks!</description>
  	<guid isPermaLink="false">post:ask.metafilter.com,2008:site.42878</guid>
  	<pubDate>Mon, 24 Jul 2006 19:56:41 -0800</pubDate>
  	<dc:creator>tweebiscuit</dc:creator>
	
	<category>apache</category>
	
	<category>configuration</category>
	
	<category>htaccess</category>
	
	<category>linux</category>
	
	<category>server</category>
	
</item>
<item>
  	<title>By: inkyz</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658821</link>	
  	<description>Could you hack it to do output some constant strings in the file in addition to the url? If you look at &lt;a href=&quot;http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html&quot;&gt;the mod_rewrite page&lt;/a&gt; it talks about RewriteMap, which reads an external file (which could be the thing you generate). I&apos;m not positive this will work -- it might only get read when the httpd.conf file is read, which wouldn&apos;t be good enough for this.&lt;br&gt;
&lt;br&gt;
Barring that, hmm, you may be out of luck with a rewrite solution. I don&apos;t see any way to read a file for rewriting purposes. It might be worth looking into writing a small cgi script (in php or whatever language) that people would hit to get the video, and it&apos;d redirect them to the appropriate place. Not as clean, but it&apos;d work.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658821</guid>
  	<pubDate>Mon, 24 Jul 2006 20:21:53 -0800</pubDate>
  	<dc:creator>inkyz</dc:creator>
</item>
<item>
  	<title>By: justkevin</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658826</link>	
  	<description>Correct me if I&apos;m misunderstanding your question, but couldn&apos;t you have a php or perl script run after you post the video that writes out a .htaccess which does the redirect you need?</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658826</guid>
  	<pubDate>Mon, 24 Jul 2006 20:30:01 -0800</pubDate>
  	<dc:creator>justkevin</dc:creator>
</item>
<item>
  	<title>By: tweebiscuit</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658854</link>	
  	<description>justkevin -- I could, but a) from what I&apos;ve been told, having a script edit .htaccess is Considered Harmful. b) I&apos;m good enough with PHP to hack my way through Wordpress, but not good enough to write such a script from scratch -- thus my hope of finding a hook in .htaccess that will allow it to read from a file I can easily output. (And yes, I can definitely have it output some constant strings in addition to the filename.)</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658854</guid>
  	<pubDate>Mon, 24 Jul 2006 20:52:25 -0800</pubDate>
  	<dc:creator>tweebiscuit</dc:creator>
</item>
<item>
  	<title>By: tweebiscuit</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658856</link>	
  	<description>ikyz, when is the httpd.conf file read? I&apos;m on a shared account, so I don&apos;t have access to httpd.conf.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658856</guid>
  	<pubDate>Mon, 24 Jul 2006 20:53:45 -0800</pubDate>
  	<dc:creator>tweebiscuit</dc:creator>
</item>
<item>
  	<title>By: inkyz</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658898</link>	
  	<description>Whoops -- doing more investigation, I see RewriteMap is only available in httpd.conf, not in .htaccess. So I think you&apos;re out of luck with RewriteMap, sorry. But it seems like you can take justkevin&apos;s suggestion, can&apos;t you? Just have your script write out a one-line .htaccess file with the RewriteRule and you should be set.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658898</guid>
  	<pubDate>Mon, 24 Jul 2006 21:36:51 -0800</pubDate>
  	<dc:creator>inkyz</dc:creator>
</item>
<item>
  	<title>By: tweebiscuit</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658906</link>	
  	<description>Hmm. Well, it will take some extra research on my part. Will it be pretty easy to output a single line to a file from WordPress? I&apos;m skeptical about my abilities to write a script from scratch, but if there&apos;s a simple way to output a variable to an arbitrary file in the middle of a PHP script I can probably handle that.&lt;br&gt;
&lt;br&gt;
A &lt;a href=&quot;http://www.google.com/search?q=php+file+output&amp;ie=utf-8&amp;oe=utf-8&amp;rls=org.mozilla:en-US:official&amp;hl=en-US&amp;client=firefox-a&quot;&gt;quick Google&lt;/a&gt; shows a few too many options to sort through -- what function / method should I be using for file output?</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658906</guid>
  	<pubDate>Mon, 24 Jul 2006 21:44:50 -0800</pubDate>
  	<dc:creator>tweebiscuit</dc:creator>
</item>
<item>
  	<title>By: tweebiscuit</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658907</link>	
  	<description>(Also, any other suggestions on ways to do this would be appreciated!)</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658907</guid>
  	<pubDate>Mon, 24 Jul 2006 21:45:15 -0800</pubDate>
  	<dc:creator>tweebiscuit</dc:creator>
</item>
<item>
  	<title>By: clord</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658927</link>	
  	<description>My first instinct is to look into using the Unix &amp;quot;environment&amp;quot; to pass information to mod_rewrite. Have Wordpress put the most recent post url into an environment variable, and then in mod_rewrite, use the environment variable. &lt;br&gt;
&lt;br&gt;
This assumes a lot. PHP should be able to set environment variables, but mod_rewrite may not be able to consume them. Furthermore, environment variables can only (strictly?) pass from parent process to child, and I doubt mod_rewrite is a child process of wordpress  they are most likely either sibling processes or in the same process. If they are in the same process, environment variables may still work. &lt;br&gt;
&lt;br&gt;
This line does suggest an alternate mode of thinking when googling, though. Good luck.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658927</guid>
  	<pubDate>Mon, 24 Jul 2006 22:10:51 -0800</pubDate>
  	<dc:creator>clord</dc:creator>
</item>
<item>
  	<title>By: Freaky</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#658936</link>	
  	<description>What&apos;s the format of the URL?  You could use RewriteCond to test it against %{TIME_*} variables and have the RewriteRule conditional on the date specified in the URL being the current date.&lt;br&gt;
&lt;br&gt;
For PHP, you want &lt;a href=&quot;http://uk.php.net/fopen&quot;&gt;fopen&lt;/a&gt;/fwrite/fputs/fclose, however, you&apos;ll almost certainly need to give the webserver write permissions on the file, which might not be a great plan.&lt;br&gt;
&lt;br&gt;
Other options include using a CGI to update your .htaccess if your provider&apos;s using suexec (so no permissions problems), using a cronjob to update it periodically, or having WordPress change the links it generates so it sends users to libsyn conditionally.&lt;br&gt;
&lt;br&gt;
Some more details on your workflow in making new posts might help narrow things down.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-658936</guid>
  	<pubDate>Mon, 24 Jul 2006 22:29:53 -0800</pubDate>
  	<dc:creator>Freaky</dc:creator>
</item>
<item>
  	<title>By: beerbajay</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#659057</link>	
  	<description>I would use &lt;a href=&quot;http://httpd.apache.org/docs/1.3/mod/mod_alias.html&quot;&gt;mod_alias&lt;/a&gt; and the &lt;a href=&quot;http://httpd.apache.org/docs/1.3/mod/mod_alias.html#redirect&quot;&gt;Redirect&lt;/a&gt; directive, spitting out a new .htaccess file each time you post. &lt;br&gt;
&lt;br&gt;
Or you could write a small PHP script that sits in between the user and the podcasts. They&apos;d fetch them by going to http://servername/getpodcast.php?file=file.ogg, which would check the modification times on the files, and if the requested file was the last updated, the script would redirect them to libsyn.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-659057</guid>
  	<pubDate>Tue, 25 Jul 2006 04:21:59 -0800</pubDate>
  	<dc:creator>beerbajay</dc:creator>
</item>
<item>
  	<title>By: tweebiscuit</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#659569</link>	
  	<description>Thanks, Freaky and beerbajay -- I&apos;ll look into those options.&lt;br&gt;
&lt;br&gt;
Our workflow is as follows: We FTP the video to a directory on our site, with a URL like this:&lt;br&gt;
&lt;br&gt;
http://www.oldeenglish.org/videos/OldeEnglish.org_-_Name_Of_Video.mov&lt;br&gt;
&lt;br&gt;
We then also upload the video to Libsyn, which gives it a URL along these lines:&lt;br&gt;
&lt;br&gt;
http://media.libsyn.com/media/aconover/OldeEnglish.org_-_Name_Of_Video.mov&lt;br&gt;
&lt;br&gt;
We then link to that video in a WordPress post -- current we manually make a Quicktime embed for every post (via a WP plugin that does most of the heavy HTML lifting), but for these purposes I could change our system to use a Wordpress custom field and put the embed code in the template, since it doesn&apos;t change post to post.&lt;br&gt;
&lt;br&gt;
However, that URL is used on quite a few templates, and of course we link to the videos outside of WordPress as well, so a an .htaccess solution would be the best in my mind, since it&apos;s the most universal possible.&lt;br&gt;
&lt;br&gt;
The PHP script isn&apos;t really a possibility -- our site has been up for years, and our URLs are well known to our audience, so I&apos;d rather not filter them through a PHP file if I can avoid it. Also, certain podcast aggregators (cough*itunes*cough) tend to balk at media files served through scripts.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-659569</guid>
  	<pubDate>Tue, 25 Jul 2006 12:06:05 -0800</pubDate>
  	<dc:creator>tweebiscuit</dc:creator>
</item>
<item>
  	<title>By: beerbajay</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#659642</link>	
  	<description>You don&apos;t need to pass the file through the php script, just use the php script to redirect to the actual file location (local if it&apos;s old, libsyn if it&apos;s new).&lt;br&gt;
&lt;br&gt;
I don&apos;t really know how the podcast aggregators would react to redirects, though... not really my area of expertise.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-659642</guid>
  	<pubDate>Tue, 25 Jul 2006 12:52:18 -0800</pubDate>
  	<dc:creator>beerbajay</dc:creator>
</item>
<item>
  	<title>By: Freaky</title>
  	<link>http://ask.metafilter.com/42878/Hardcore-Apache-question-How-to-have-an-htaccess-file-pull-from-WordPress#660085</link>	
  	<description>You could modify the .htaccess every time you upload (something you could automate with a local script) and simply do:&lt;br&gt;
&lt;br&gt;
RedirectTemp /video/OldeEnglish.org_-_Name_Of_Video.mov http://media.libsyn.com/media/aconover/OldeEnglish.org_-_Name_Of_Video.mov&lt;br&gt;
&lt;br&gt;
You could also map the URLs to a PHP script that performs redirects based on some logic and file modification times, but that might be a bit over the top; it would potentially allow more flexibility without invalidating your current URL scheme, but it would mean either a lot more redirects or writing half a webserver to serve files directly from PHP properly.</description>
  	<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.42878-660085</guid>
  	<pubDate>Tue, 25 Jul 2006 18:35:50 -0800</pubDate>
  	<dc:creator>Freaky</dc:creator>
</item>

    </channel>
</rss>
