mod_rewrite rules for SilverStripe CMS

#1
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!
 
#3
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?
 

mistwang

LiteSpeed Staff
#5
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
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!
 

mistwang

LiteSpeed Staff
#7
$_SERVER[DOCUMENT_ROOT] is a PHP variable, not a rewrite variable, just replace it with %{DOCUMENT_ROOT}, the rewrite rules should work with LiteSpeed.
 
#9
Or, patch their installer code, search for the code that tests server string "Apache", add code to return true when server signature contains "LiteSpeed".
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!
 

mistwang

LiteSpeed Staff
#10
Change the code to
Code:
 if ( function_exists('apache_get_modules') ||
   stristr($_SERVER['SERVER_SIGNATURE'], 'Apache')||
   stristr($_SERVER['SERVER_SIGNATURE'],'LiteSpeed'))
 
Last edited:

mistwang

LiteSpeed Staff
#14
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]
 
#17
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
 
Top