PDA

View Full Version : mod_rewrite rules for SilverStripe CMS


redking
11-18-2007, 06:21 PM
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 (http://www.silverstripe.com/) 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!

mistwang
11-18-2007, 06:42 PM
You can setup it as it was with Apache.

redking
11-18-2007, 06:47 PM
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
11-18-2007, 06:55 PM
You can research what rewrite rules are used for Apache, then just copy over.

mistwang
11-18-2007, 06:56 PM
Or, patch their installer code, search for the code that tests server string "Apache", add code to return true when server signature contains "LiteSpeed".

redking
11-19-2007, 10:25 AM
I believe this is the set of rewrite rules for Apache.

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
11-19-2007, 10:35 AM
$_SERVER[DOCUMENT_ROOT] is a PHP variable, not a rewrite variable, just replace it with %{DOCUMENT_ROOT}, the rewrite rules should work with LiteSpeed.

mistwang
11-19-2007, 10:37 AM
$_SERVER[DOCUMENT_ROOT] is a PHP variable, not a rewrite variable, just replace it with %{DOCUMENT_ROOT}, the rewrite rules should work with LiteSpeed.


Actually, just removed it.

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

redking
11-19-2007, 07:47 PM
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:

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
11-19-2007, 08:01 PM
Change the code to
if ( function_exists('apache_get_modules') ||
stristr($_SERVER['SERVER_SIGNATURE'], 'Apache')||
stristr($_SERVER['SERVER_SIGNATURE'],'LiteSpeed'))

redking
11-19-2007, 08:06 PM
Tried that. Still nothing. :(

mistwang
11-19-2007, 08:18 PM
Do you get any rewrite rule in .htaccess?

redking
11-19-2007, 08:27 PM
Unfortunately, that did not work either.
I am at a complete loss.

mistwang
11-19-2007, 10:30 PM
Try this in ".htaccess"

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]

pjssms
12-13-2008, 09:04 AM
Has this worked ?

I am with the same issue.

Thank you,

Paulo Santos

mistwang
12-13-2008, 07:37 PM
the rewrite rule for Apache should work with Litespeed.

pjssms
12-14-2008, 06:00 AM
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

mistwang
12-14-2008, 10:00 AM
It is a file/directory permission problem, not related to rewrite rule.

pjssms
12-14-2008, 01:59 PM
have you seen the name of the file ? it seems that something is missing like the /