Rewrite rule Johncms with Openlitespeed 1.3

#1
Hello, i have a code JohnCMS with rewrite-rule as follows :
Code:
Options -Indexes
ErrorDocument 403 /index.php
ErrorDocument 404 http://m.domain.com
ErrorDocument 500 /index.php
DirectoryIndex index.php

AddDefaultCharset UTF-8
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault A1209600
  <FilesMatch \.php$>
    ExpiresActive Off
  </FilesMatch>
</IfModule>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.m.domain.com$
RewriteRule (.*) http://m.domain.com/$1 [R=301,L]
RewriteRule robots.txt robot.php
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$)
RewriteRule .* - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)$ http://m.domain.com/$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/$ index.php?page=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^tags/(.*).([0-9]+)/$ forum/tag.php?search=$1&page=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^tags/(.*)/$ forum/tag.php?search=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/$ forum/index.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ http://m.domain.com/$1/$2/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ forum/index.php?url=$1&page=$2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^tags/([a-zA-Z0-9_+-]+)$ http://m.domain.com/tags/$1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page/([a-zA-Z0-9_-]+)/$ forum/page.php?url=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^tags/([a-zA-Z0-9_+-]+)$ http://m.domain.com/tags/$1/ [R=301,L]
It does not work on Openlitespeed 1.3.6 (404 not found)




Note: It can run on Nginx with the following rules :



Code:
rewrite robots.txt /robot.php;
rewrite ^/([a-zA-Z0-9_-]+)$ http://m.domain.com/$1/ redirect;
rewrite ^/([0-9]+)/$ /index.php?page=$1 break;
rewrite ^/tags/(.*).([0-9]+)/$ /forum/tag.php?search=$1&page=$2 break;
rewrite ^/tags/(.*)/$ /forum/tag.php?search=$1 break;
rewrite ^/([a-zA-Z0-9_-]+)/$ /forum/index.php?url=$1 break;
rewrite ^/([a-zA-Z0-9_-]+)/([0-9]+)$ http://m.domain.com/$1/$2/ redirect;
rewrite ^/([a-zA-Z0-9_-]+)/([0-9]+)/$ /forum/index.php?url=$1&page=$2 break;
rewrite ^/tags/([a-zA-Z0-9_+-]+)$ http://domain.com/tags/$1/ redirect;
rewrite ^/page/([a-zA-Z0-9_-]+)/$ /forum/page.php?url=$1 break;
rewrite ^/tags/([a-zA-Z0-9_+-]+)$ http://m.domain.com/tags/$1/ redirect;

So what's wrong with rewrite-rule, how to run it on Openlitespeed? Thanks all!^^
 
#2
openlitespeed support per-server rewriterule but not per-directory. for the difference please refer the official document:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

so put these rules in vhost configuration file but not .htaccess. and need some slight change, for example:
Code:
RewriteRule ^([a-zA-Z0-9_-]+)$ http://m.domain.com/$1/ [R=301,L]
==>
Code:
RewriteRule ^/([a-zA-Z0-9_-]+)$ http://m.domain.com/$1/ [R=301,L]
it's equal to nginx rule:
Code:
rewrite ^/([a-zA-Z0-9_-]+)$ http://m.domain.com/$1/ redirect;
 

lsmichael

Active Member
#4
This is a very good idea. It's something that I believe has been suggested before and something that we've definitely been considering. We haven't had time to implement it before, but I'll bring it up again and see if we can't get it on the to do list. (If someone else wants to set up a site like that, we'd be very grateful and would, of course, recommend it to users.)

Cheers,

Michael
 
Top