Jump to:

22976 Posts in 11702 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » Retina feature in htaccess files

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 600 Views
  • borriej
    Avatar
    Community Member
    267 Posts

    Retina feature in htaccess files Link to this post

    hello,

    i would like to add a feature into the SilverStripe htaccess, but my htaccess experience is limited.. resulting in internal server errors ;)

    https://github.com/Retina-Images/Retina-Images/blob/master/.htaccess

    <IfModule mod_rewrite.c>

    Options +FollowSymlinks
    RewriteEngine On

    # Option 1 (default)
    # ==================
    # Use this if your website runs in the root of the domain.
    # i.e. http://example.com/index.html
    #
    RewriteBase /
    RewriteRule \.(?:jpe?g|gif|png|bmp)$ /retinaimages.php [L]

    # Option 2
    # ==================
    # Use this if your website runs in a sub-directory.
    # i.e. http://example.com/website/directory/index.html
    #
    #RewriteBase /website/directory
    #RewriteRule \.(?:jpe?g|gif|png|bmp)$ /website/directory/retinaimages.php [L]

    </IfModule>

    how do i add that into the default htaccess?

    ### SILVERSTRIPE START ###

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

    <Files web.config>
       Order deny,allow
       Deny from all
    </Files>

    ErrorDocument 404 /assets/error-404.html
    ErrorDocument 500 /assets/error-500.html

    <IfModule mod_alias.c>
       RedirectMatch 403 /silverstripe-cache(/|$)
    </IfModule>

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteBase /

       RewriteCond %{REQUEST_URI} ^(.*)$
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
       
    </IfModule>

    ### SILVERSTRIPE END ###

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Retina feature in htaccess files Link to this post

    Any one?

  • borriej
    Avatar
    Community Member
    267 Posts

    Re: Retina feature in htaccess files Link to this post

    Solved it..

    just used another retina plugin with different htaccess:

    see http://shauninman.com/tmp/retina/

    ### SILVERSTRIPE START ###
    php_value date.timezone "Europe/Amsterdam"
    php_value upload_max_filesize 200M
    php_value post_max_size 200M

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

    <Files web.config>
       Order deny,allow
       Deny from all
    </Files>

    ErrorDocument 404 /assets/error-404.html
    ErrorDocument 500 /assets/error-500.html

    <IfModule mod_alias.c>
       RedirectMatch 403 /silverstripe-cache(/|$)
    </IfModule>

    <IfModule mod_rewrite.c>
       Options -MultiViews
       RewriteEngine On
       RewriteBase /
       RewriteCond %{REQUEST_URI} ^(.*)$
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule .* sapphire/main.php?url=%1&%{QUERY_STRING} [L]
       RewriteCond %{HTTP_COOKIE} HTTP_IS_RETINA [NC]
       RewriteCond %{REQUEST_FILENAME} !@2x
       RewriteRule ^(.*)\.(gif|jpg|png)$ $1@2x.$2
       # if @2x isn't available fulfill the original request
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteRule ^(.*)@2x\.(gif|jpg|png)$ $1.$2

    </IfModule>

    ### SILVERSTRIPE END ###

    Page.ss

    in your head use

    <script>if((window.devicePixelRatio===undefined?1:window.devicePixelRatio)>1)
       document.cookie='HTTP_IS_RETINA=1;path=/';</script>

    600 Views
Page: 1
Go to Top

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

Comments on this website? Please give feedback.