Jump to:

4951 Posts in 13999 Topics by 1491 members

Installing SilverStripe

SilverStripe Forums » Installing SilverStripe » Html Code showing up as text

Getting SilverStripe up and running on your computer and on your web server.

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

Page: 1
Go to End
Author Topic: 395 Views
  • 2fik
    Avatar
    Community Member
    4 Posts

    Html Code showing up as text Link to this post

    Hello,
    I installed Silverstripe 3.1.2 and after I added a code in .htaccess file because was empty after installation and All works fine only when I go to MySite/Security/ I see html code as text.

    My htaccess file is:

    ### 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>

    # This denies access to all yml files, since developers might include sensitive
    # information in them. See the docs for work-arounds to serve some yaml files
    <Files *.yml>
    Order allow,deny
    Deny from all
    </Files>

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

    <IfModule mod_rewrite.c>
    SetEnv HTTP_MOD_REWRITE On
    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase '/'

    RewriteRule ^vendor(/|$) - [F,L,NC]
    RewriteRule silverstripe-cache(/|$) - [F,L,NC]
    RewriteRule composer\.(json|lock) - [F,L,NC]
    RewriteRule ^logout/?$ Security/logout [NC,L]
    RewriteRule ^login/?$ Security/login [NC,L]

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

    and the html what I see is my default home page.

  • 2fik
    Avatar
    Community Member
    4 Posts

    Re: Html Code showing up as text Link to this post

    Hi,
    I reinstalled my Site and the same problem look at the site :
    http://cheraga.net/Security/

    is there any solution?

    Thanks.

  • martimiz
    Avatar
    Forum Moderator
    1067 Posts

    Re: Html Code showing up as text Link to this post

    If .htaccess is made writable before installing SilverStripe it shouldn't be empty after a proper installation... But to make sure I tested with your htaccess and couldn't reproduce your problem.

    Yoursite/Security isn't a 'valid' url, it expects either login or logout to be added. So if you go there anyway, the Security class calls its httpError('404') function. This would normally result in just a plain white page, but in your case it displays the raw HTML of the 404 error page instead.

    Looking at the SilverStripe code, this seems strange behaviour. Did you install a clean version of silverstripe 3.1.2, without any extra modules or custom code changes?

  • 2fik
    Avatar
    Community Member
    4 Posts

    Re: Html Code showing up as text Link to this post

    Hi,
    yes I installed a clean version of silverstripe 3.1.2 without module and the problem is the same on my local machine (Mac os 10.9.1) and I didn't upload installed files from my local machine to my server but i make a clean install.

    Thanks.

  • 2fik
    Avatar
    Community Member
    4 Posts

    Re: Html Code showing up as text Link to this post

    Hi,
    I found that action index after Security (/Security/index) invoke SS_HTTPResponse_Exception look in file RequestHandler.php

    catch (SS_HTTPResponse_Exception $e) {
       return $e->getResponse();
    }


    but I don’t know why it returns $e->getResponce and not httpError..

    I change a code in the file HTTPResponse.php from

    $response->addHeader('Content-Type', 'text/plaintext');
    to
    if($body == "" AND $statusDescription == ""){
       $response->addHeader('Content-Type', 'text/html; charset=utf-8');
    }else{
    // Error responses should always be considered plaintext, for security reasons
       $response->addHeader('Content-Type', 'text/plaintext');         
    }
    and now work without problem.
    But I think is better when we change $e->getResponse() to HttpError or is there another solution?

    395 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.