mod_rewrite rules for SilverStripe CMS

Discussion in 'Apache Migration/Compatibility' started by redking, Nov 19, 2007.

  1. redking

    redking New Member

    Hi,

    I just switched to a new hosting provider who's servers are powered by LiteSpeed. The site I am hosting there is built on the SilverStripe CMS tool. The problem I'm having is that SilverStripe currently does not support LiteSpeed out of the box. It was built for use on Apache and lighttpd web servers. After discussing this with both SilverStripe developers as well as my hosting support, the conclusion is that I can simply create new mod_rewrite rule in the .htaccess. Good. One problem-doing so goes just beyond my skill set. That being said, I would really like to find out how this is done. Can anyone point me in the right direction to where might find out how to do this, or perhaps even be willing to walk me through it? That would be greatly appreciated.

    Thx!
  2. mistwang

    mistwang LiteSpeed Staff

    You can setup it as it was with Apache.
  3. redking

    redking New Member

    I've tried several times to get it to install as if it were Apache. I get the following webserver config warnings:

    • Server Software warning saying: I can't tell what webserver you are running. Without Apache I can't tell if mod_rewrite is enabled.
    • mod_rewrite warning saying: I can't tell whether mod_rewrite is running. You may need to configure a rewriting rule yourself.

    Thoughts?
  4. mistwang

    mistwang LiteSpeed Staff

    You can research what rewrite rules are used for Apache, then just copy over.
  5. mistwang

    mistwang LiteSpeed Staff

    Or, patch their installer code, search for the code that tests server string "Apache", add code to return true when server signature contains "LiteSpeed".
  6. redking

    redking New Member

    I believe this is the set of rewrite rules for Apache.

    PHP:
    RewriteEngine On

    RewriteCond 
    %{REQUEST_URI} !(\.gif)|(\.jpg)|(\.png)|(\.css)|(\.js)|(\.php)$ 

    RewriteCond %{REQUEST_URI} ^(.*)$
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule 
    .* $_SERVER[DOCUMENT_ROOT]/sapphire/main.php?url=%1&%{QUERY_STRING} [L]
    How do I modify this for use on a LiteSpeed server?

    Thx!
  7. mistwang

    mistwang LiteSpeed Staff

    $_SERVER[DOCUMENT_ROOT] is a PHP variable, not a rewrite variable, just replace it with %{DOCUMENT_ROOT}, the rewrite rules should work with LiteSpeed.
  8. mistwang

    mistwang LiteSpeed Staff

    Actually, just removed it.

    RewriteRule .* /sapphire/main.php?url=%1&%{QUERY_STRING} [L]
  9. redking

    redking New Member

    Is that what you are referring to here:

    PHP:
    function isRunningApache($testDetails) {
            
    $this->testing($testDetails);
            if(
    function_exists('apache_get_modules') || stristr($_SERVER['SERVER_SIGNATURE'], 'Apache'))
                return 
    true;
            
            
    $this->warning($testDetails);
            return 
    false;
        }
    What do I need to do in order to modify it for LiteSpeed?

    Thx!
  10. mistwang

    mistwang LiteSpeed Staff

    Change the code to
    Code:
     if ( function_exists('apache_get_modules') ||
       stristr($_SERVER['SERVER_SIGNATURE'], 'Apache')||
       stristr($_SERVER['SERVER_SIGNATURE'],'LiteSpeed'))
    Last edited: Nov 20, 2007
  11. redking

    redking New Member

    Tried that. Still nothing. :(
  12. mistwang

    mistwang LiteSpeed Staff

    Do you get any rewrite rule in .htaccess?
  13. redking

    redking New Member

    Unfortunately, that did not work either.
    I am at a complete loss.
  14. mistwang

    mistwang LiteSpeed Staff

    Try this in ".htaccess"
    Code:
    RewriteEngine On 
     
    
    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] 
    
  15. pjssms

    pjssms New Member

    silverstripe on litespped

    Has this worked ?

    I am with the same issue.

    Thank you,

    Paulo Santos
  16. mistwang

    mistwang LiteSpeed Staff

    the rewrite rule for Apache should work with Litespeed.
  17. pjssms

    pjssms New Member

    I have this on .htaccess on silver directorty.

    ### SILVERSTRIPE START ###
    <IfModule mod_dir.c>
    DirectorySlash Off
    </IfModule>

    RewriteEngine On
    RewriteBase /silver

    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]
    ### SILVERSTRIPE END ###

    I got this error

    Cannot write manifest file! Check permissions of /tmp/silverstripe-cache-home-ahosting-public_html-silver/manifest_home_ahosting_public_html_silver_sapphire_main.php
  18. mistwang

    mistwang LiteSpeed Staff

    It is a file/directory permission problem, not related to rewrite rule.
  19. pjssms

    pjssms New Member

    have you seen the name of the file ? it seems that something is missing like the /

Share This Page