Some rewrites not working

Discussion in 'General' started by Tony, Dec 30, 2008.

  1. Tony

    Tony Member

    To my surprise some rewrite rules are not working for me. The script being used is called iVidPlay. and is put into a sub folder which I assume is fine.

    Here's what the .htaccess file for this script looks like:

    Code:
    Options +FollowSymLinks
    
    RewriteEngine on
    RewriteRule ^category/([0-9]+)/.*\.p([0-9]+)\.(htm|html)$ listplaylists.php?cat=$1&p=$2 [QSA,L]
    RewriteRule ^category/([0-9]+)/.*\.(htm|html)$ listplaylists.php?cat=$1 [QSA,L]
    RewriteRule ^playlists/([0-9]+)/.*\.p([0-9]+)\.(htm|html)$ listplaylists.php?uid=$1&p=$2 [QSA,L]
    RewriteRule ^playlists/([0-9]+)/.*\.(htm|html)$ listplaylists.php?uid=$1 [QSA,L]
    RewriteRule ^videos/([0-9]+)/.*\.p([0-9]+)\.(htm|html)$ listvideos.php?uid=$1&p=$2 [QSA,L]
    RewriteRule ^videos/([0-9]+)/.*\.(htm|html)$ listvideos.php?uid=$1 [QSA,L]
    RewriteRule ^playlist/([0-9]+)/.*\.p([0-9]+)\.(htm|html)$ listvideos.php?pid=$1&p=$2 [QSA,L]
    RewriteRule ^playlist/([0-9]+)/.*\.(htm|html)$ listvideos.php?pid=$1 [QSA,L]
    RewriteRule ^tag/(.*)\.p([0-9]+)$ listvideos.php?tag=$1&p=$2 [QSA,L]
    RewriteRule ^tag/(.*)$ listvideos.php?tag=$1 [QSA,L]
    RewriteRule ^video/([0-9]+)/.*\.(htm|html)$ showvideo.php?id=$1 [QSA,L]
    RewriteRule ^playlists(\.p([0-9]+))?\.(htm|html)$ listplaylists.php?p=$2 [QSA,L]
    RewriteRule ^videoslist(\.p([0-9]+))?\.(htm|html)$ listvideos.php?p=$2 [QSA,L]
    RewriteRule ^member/([0-9]+)/.*\.(htm|html)$ member/user.php?id=$1 [QSA,L]
    RewriteRule ^memberslist(\.p([0-9]+))?\.(htm|html)$ listusers.php?p=$2 [QSA,L]
    RewriteRule ^index\.(htm|html)$ index.php [QSA,L]
    RewriteRule ^fckeditor/(.*)$ fckeditor/$1 [QSA,L]
    RewriteRule ^([a-z0-9_\-\/]+)(\.p([0-9]+))?\.(htm|html)$ callmodule.php?url=$1&p=$3 [QSA,L]
    
    The only rule that works is the index one the others like say: videos/newest.html do not work which did in apache.
  2. Tony

    Tony Member

    Mystery solved.

    The user did not set RewriteBase to the folder where the script was and the .htaccess. Now they claimed without that it still worked fine with Apache. But who knows with users
  3. Tony

    Tony Member

    Ran into another one and this one I'm not really sure on considering the rewritelog tells me nothing. This one however gives a 500 internal server error when visiting the url.

    This is the error I see: [ERROR] [REWRITE] Can not determine proxy host name


    Here's the rewrite:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^dev.domain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.dev.domain.com$
    RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12004%{REQUEST_URI}" [P,QSA,L]
    
    RewriteCond %{HTTP_HOST} ^dev.domain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.dev.domain.com$
    RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12004%{REQUEST_URI}" [P,QSA,L]
    

    Any idea's? This was used for cPanel's mongrel ruby system and worked fine on Apache. You can visit the http://domain.com:12004/ fine if that helps at all?
  4. Tony

    Tony Member

    I've figured it out.

    I had to change the rules to be:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^dev.domain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.dev.domain.com$
    RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12004/$1" [P,QSA,L]
    
    RewriteCond %{HTTP_HOST} ^dev.domain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.dev.domain.com$
    RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12004/$1" [P,QSA,L]
    

    Would it be possible to make the rule I posted above work as well? It would make things easier in terms of compatibility.
  5. mistwang

    mistwang LiteSpeed Staff

    The original rule works properly with our cPanel test server.
    Can you post the rewrite log for a request that does not work? Maybe %{REQUEST_URI} has been interpreted to something else.
  6. Tony

    Tony Member

    Is it "RewriteLog 9" in the vhost to bring up more details? I had that and I got nothing back on that ruleset I posted. I'll play around with this on my own ruby app and see if it produces the same sort of thing.
  7. mistwang

    mistwang LiteSpeed Staff

    RewriteLogLevel 9
  8. Tony

    Tony Member

    Ahh that was my issue there. Here's what it returned:



    Code:
    2009-01-03 17:46:11.246 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Rule: Match '' with pattern '^(.*)$', result: 2
    2009-01-03 17:46:11.246 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Cond: Match 'dev.domain.com' with pattern '^dev.domain.com$', result: 1
    2009-01-03 17:46:11.246 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Source URI: '' => Result URI: 'http://127.0.0.1:12002'
    2009-01-03 17:46:11.246 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Last Rule, stop!
    2009-01-03 17:46:11.246 [ERROR] [REWRITE] Can not determine proxy host name
    2009-01-03 17:46:11.247 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Rule: Match '500.shtml' with pattern '^(.*)$', result: 2
    2009-01-03 17:46:11.247 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Cond: Match 'dev.domain.com' with pattern '^dev.domain.com$', result: 1
    2009-01-03 17:46:11.247 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Source URI: '500.shtml' => Result URI: 'http://127.0.0.1:12002500.shtml'
    2009-01-03 17:46:11.247 [INFO] [72.39.65.19:52445-0#APVH_dev.domain.com] [REWRITE] Last Rule, stop!
    
    dev.domain.com was a subdomain added to the account. The rewrite was added using the create rewrite option in cpanel's ruby system.

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^dev.domain.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www.dev.domain.com$
    RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12002%{REQUEST_URI}" [P,QSA,L]
    
  9. Tony

    Tony Member

    Another thing I'm wondering about is with .htaccess and mod_rewrite if you do not specify a rewritebase in a directory it assumes you're talking about the domain root. For example

    http://domain.com/blog/

    I have a ton of rewrite rules if I do not specify the RewriteBase of blog then it sends the rewrite rules to domain.com/index.php opposed to domain.com/blog/index.php. In apache these rules seem to work, but in LiteSpeed it does not make the assumption that the base is the directory we're working in.
  10. mistwang

    mistwang LiteSpeed Staff

    Please download and try updated 3.3.24 or 4.0b3 package, it should work better regarding RewriteBase .
  11. Tony

    Tony Member


    Tried the the latest 4.0b3 x86_64 and it still defaults the base to / when inside another directory.
  12. Tony

    Tony Member

    For anyone else who's encountered this seems to be solved now at least in the beta I tried.

Share This Page