Need Corrected htaccess File

Posted by Vince Kronlein on Server Fault See other posts from Server Fault or by Vince Kronlein
Published on 2013-11-11T15:41:24Z Indexed on 2013/11/11 15:57 UTC
Read the original article Hit count: 331

Filed under:
|
|

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.

© Server Fault or respective owner

Related posts about .htaccess

Related posts about mod-rewrite