Login | Forgot password | Register

X

What is OpenID?

OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.

With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.

For more information visit the official OpenID site.

Jump to:

2498 Posts in 734 Topics by 543 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Static Publisher - .htaccess - not accessing the .html files

Page: 1
Go to End
Author Topic: Static Publisher - .htaccess - not accessing the .html files 640 Views
  • Gutur
    avatar
    Community Member
    16 posts

    Static Publisher - .htaccess - not accessing the .html files Link to this post

    Hi everyone, I fiddled with this for a few hours now and I can't get it to work.
    I followed the instructions and also read this post.
    I'm testing this on a silverstripe in a subdirectory (/mydir/) of my server and the CMS per se works perfect.
    So, on http://www.mysite.com/mydir/dev/buildcache?flush=1 it also builds the cache pages just fine, but I can't get the .htaccess right...

    This is what resides in /mydir/.htaccess:

    ### SILVERSTRIPE START ###
    <Files *.ss>
    Order deny,allow
    Deny from all
    Allow from 127.0.0.1
    </Files>

    <IfModule mod_rewrite.c>
    RewriteEngine On
    #RewriteBase /mydir

    ## CONFIG FOR DEV ENVIRONMENTS

    # Cached content - mydir subdirectory
    RewriteCond %{REQUEST_METHOD} ^GET$
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond %{REQUEST_URI} ^/mydir/(.*)$
    RewriteCond %{REQUEST_URI} /mydir/(.*[^/])/?$
    RewriteCond %{DOCUMENT_ROOT}/mydir/cache/%1.html -f
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /mydir/cache/%1.html [L]

    # Cached content - homepage
    RewriteCond %{REQUEST_METHOD} ^GET$
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond %{REQUEST_URI} ^/mydir/?$
    RewriteCond /mydir/cache/index.html -f
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /mydir/cache/index.html [L]

    ## CONFIG FOR TEST/LIVE ENVIRONMENTS

    # Cached content - live webserver
    RewriteCond %{REQUEST_METHOD} ^GET$
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond %{REQUEST_URI} /(.*[^/])/?$
    RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /cache/%1.html [L]

    # Cached content - homepage
    RewriteCond %{REQUEST_METHOD} ^GET$
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond %{REQUEST_URI} ^/?$
    RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /cache/index.html [L]

    ## DYNAMIC CONFIG
    # Dynamic content
    RewriteCond %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$
    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    </IfModule>
    ### SILVERSTRIPE END ###

    But somehow the rewriterules never kick in. It always gives back the data from the CMS.
    I know a bit about apache rewriterules and tried out a lot, patched here and there to find what's keeping it from kicking in and so on. But now i think I can't look straight at it anymore and have to ask for help

    Does anybody find the general error in this .htaccess?

  • Gutur
    avatar
    Community Member
    16 posts

    Re: Static Publisher - .htaccess - not accessing the .html files Link to this post

    Ok, found out some more. With this it works, partially:

    RewriteEngine On
    #RewriteBase /mydir

    ## CONFIG FOR DEV ENVIRONMENTS

    # Cached content - mydir subdirectory
    RewriteCond %{REQUEST_METHOD} ^GET$
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond %{REQUEST_URI} ^/mydir/(.*)$
    RewriteCond %{REQUEST_URI} /mydir/(.*[^/])/?$
    #RewriteCond %{DOCUMENT_ROOT}/mydir/cache/%1.html -f
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /mydir/cache/%1.html [L]

    # Cached content - homepage
    RewriteCond %{REQUEST_METHOD} ^GET$
    RewriteCond %{QUERY_STRING} ^$
    RewriteCond %{REQUEST_URI} ^/mydir/?$
    #RewriteCond %{DOCUMENT_ROOT}/mydir/cache/index.html -f
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* /mydir/cache/index.html [L]

    It now hits for all pages that have a corresponding "name.html" in the cache directory but since two lines are commented out it never falls back if there isn't one.
    Seems that the check "-f (is regular file)" always returns False... at least on my host.
    Or does anyone find an error in those two lines and me is just too stoopied?
    ..brain... hurts ... must ... look at ... something ... different ....

  • Gutur
    avatar
    Community Member
    16 posts

    Re: Static Publisher - .htaccess - not accessing the .html files Link to this post

    WEEEELLLLLLLL with my ISP "%{DOCUMENT_ROOT}" isn't giving back the document root, no way, Sir!
    Figured it out via phpinfo(), hardhacked it into the .htaccess and voila, works like a charm.
    Man, is that ISP crap, going to change tomorrow Now for some Episodes of Spongebob to wipe my brain clear...

  • Garrett
    avatar
    Community Member
    149 posts

    Re: Static Publisher - .htaccess - not accessing the .html files Link to this post

    Hi,

    When you run your site from cache-- do all the links show up with "/index.php/" in front of them?? This is really killing me. The base href is appending this for some weird reason:

    <base href="http://www.mysite.com/index.php/" />

    Have you see this?

    Thanks,
    Garrett

    640 Views
Page: 1
Go to Top

Currently Online: cardinale

Welcome to our latest member: g6

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.