I'm attempting to use a wordpress plugin called WP Fast Cache which creates static html files from all your posts, pages and categories.
It creates the following directory structure inside wp-content:
wp_fast_cache example.com pagename index.html categoryname postname index.html basically just a nested directory structure and a final index.html for each item.
But the htaccess edits it makes are crazy.
#start_wp_fast_cache - do not remove this comment <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} ^(GET) RewriteCond /home/user/public_html/wp-content/wp_fast_cache/%{HTTP_HOST}%{REQUEST_URI}x__query__x%{QUERY_STRING}index.html -f RewriteCond %{HTTP_USER_AGENT} !(iPhone|Windows\sCE|BlackBerry|NetFront|Opera\sMini|Palm\sOS|Blazer|Elaine|^WAP.*$|Plucker|AvantGo|Nokia) RewriteCond %{HTTP_COOKIE} !(wordpress_logged_in) [NC] RewriteRule ^(.*)$ /home/user/public_html/wp-content/wp_fast_cache/%{HTTP_HOST}%{REQUEST_URI}x__query__x%{QUERY_STRING}index.html [L] RewriteCond %{REQUEST_METHOD} ^(GET) RewriteCond %{QUERY_STRING} ^$ RewriteCond /home/user/public_html/wp-content/wp_fast_cache/%{HTTP_HOST}%{REQUEST_URI}index.html -f RewriteCond %{HTTP_USER_AGENT} !(iPhone|Windows\sCE|BlackBerry|NetFront|Opera\sMini|Palm\sOS|Blazer|Elaine|^WAP.*$|Plucker|AvantGo|Nokia) RewriteCond %{HTTP_COOKIE} !(wordpress_logged_in) [NC] RewriteRule ^(.*)$ /home/user/public_html/wp-content/wp_fast_cache/%{HTTP_HOST}%{REQUEST_URI}index.html [L] </IfModule> #end_wp_fast_cache No matter how I try and work this out I get a 404 not found. And not the Wordpress 404, and janky apache 404.
I need to find the correct syntax to route all requests that don't exist ie: files or directories to:
wp-content/wp_fast_cache/hostname/request_uri/ So for example:
Page: example.com/about-us/ => wp-content/wp_page_cache/example.com/about-us/index.html
Post: example.com/my-category/my-awesome-post/ => wp-content/wp_fast_cache/example.com/my-category/my-awesome-post/index.html
Category: example.com/news/ => wp-content/wp_fast_cache/example.com/news/index.html
Any help is appreciated.
--EDIT--
It seems after a bunch of reading and searching that this is the Droid I'm looking for:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css) RewriteRule ^([^?]*) wp-content/wp_fast_cache/example.com/$1 [L] </IfModule> yet sadly ... it doesn't seem to work, what I am doing wrong?
--EDIT--
Ok, it works properly IF the cached pages are already created, but fails when trying to fetch the original pages in order to cache them.
If I have nothing in the htaccess and build all the cache pages, then add the htaccess, it will route correctly, but that won't allow me to build new pages as I add posts or pages to the blog.
Since the pages are dynamic the code I posted will try and find the pages in the cache, and since they aren't found, it creates a new cache page that is the result of the request ie: all my new pages are 404 pages :P
So I need to find a way to test for the cache page, and if not found, route to the dynamic page, then this should work perfect.