Some rewrites not working

Tony

Well-Known Member
#1
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.
 

Tony

Well-Known Member
#2
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
 

Tony

Well-Known Member
#3
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?
 

Tony

Well-Known Member
#4
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.
 

mistwang

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

Tony

Well-Known Member
#6
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.
 

Tony

Well-Known Member
#8
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]
 

Tony

Well-Known Member
#9
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.
 
Top