problem with rewrite & 404 error

#1
Hello,

I use rewrite rules to set up subdomains. Ive also set up 404 redirection to catch all traffic on currently `unused` subdomains ( ive also set it on in Customized Error Pages section ). Those are the rules which i use:

RewriteCond %{SERVER_NAME} !^www\.example\.com$
RewriteCond %{SERVER_NAME} ^(www\.)?([a-z-]+)\.example\.com$
RewriteRule ^/(.*)$ /home/examplecom/public_html/%2/$1
ErrorDocument 404 /home/examplecom/public_html/index.html
The problem is that it only works for a http://example.com . If there is no dir `/home/examplecom/public_html/sss` and i try to access sss.example.com i simply get
404 Not Found
The resource requested could not be found on this server! Powered By LiteSpeed Web Server
Lite Speed Technologies is not responsible for administration and contents of this web site!
( The traffic isnt redirected )

Is this a rewrite bug? Why `Customized Error Pages` doesnt work for the all subdomains in this vHost? Is there any way i can fix that or this is a litespeed bug?

Best Regards
Lukasz
 

mistwang

LiteSpeed Staff
#2
I think you probably did not configure the listener to vhost mapping properly, you should use "*" or "*.example.com" as the matching domain.
 
#3
I use `*` so this is not a problem. I didnt mention. It maps the domains.
If there is a directory `test` and i enter test.example.com it will display the site located in /home/examplecom/www/test/.

The problem is only with 404 error redirection
 

mistwang

LiteSpeed Staff
#4
The ErrorDocument directive bolow the rewrite rule does not work, only the vhost customized error page option works.
Can you post some debug logging. one working for example.com, one not working.
 
#5
For working subdomain:

2006-06-15 18:00:56.020 [INFO] [myIP:20646-0#example.com] [REWRITE] Rule: Match '/' with pattern '^/(.*)$', result: 2
2006-06-15 18:00:56.020 [INFO] [myIP:20646-0#example.com] [REWRITE] Cond: Match 'tester.example.com' with pattern '^www\.example\.com$', result: -1
2006-06-15 18:00:56.020 [INFO] [myIP:20646-0#example.com] [REWRITE] Cond: Match 'tester.example.com' with pattern '^(www\.)?([a-z-]+)\.example\.com$', result: 3
2006-06-15 18:00:56.020 [INFO] [myIP:20646-0#example.com] [REWRITE] Source URI: '/' => Result URI: '/home/examplepl/public_html/tester/'
2006-06-15 18:00:56.020 [INFO] [myIP:20646-0#example.com] [REWRITE] strip rewrite base: '/' from URI: '/'
2006-06-15 18:00:56.020 [INFO] [myIP:20646-0#example.com] [REWRITE] Rule: Match '' with pattern '^([^.]+)(\.html)?$', result: -1
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Rule: Match '/favicon.ico' with pattern '^/(.*)$', result: 2
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Cond: Match '/favicon.ico' with pattern '^/xstaty', result: -1
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Cond: Match 'tester.example.com' with pattern '^www\.example\.com$', result: -1
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Cond: Match 'tester.example.com' with pattern '^(www\.)?([a-z-]+)\.example\.com$', result: 3
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Source URI: '/favicon.ico' => Result URI: '/home/examplepl/public_html/tester/favicon.ico'
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] strip rewrite base: '/' from URI: '/favicon.ico'
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Rule: Match 'favicon.ico' with pattern '^([^.]+)(\.html)?$', result: -1
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] File not found [/home/examplepl/public_html/tester/favicon.ico]
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Rule: Match '/' with pattern '^/(.*)$', result: 2
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Cond: Match '/favicon.ico' with pattern '^/xstaty', result: -1
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Cond: Match 'tester.example.com' with pattern '^www\.example\.com$', result: -1
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Cond: Match 'tester.example.com' with pattern '^(www\.)?([a-z-]+)\.example\.com$', result: 3
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] Source URI: '/' => Result URI: '/home/examplepl/public_html/tester/'
2006-06-15 18:00:56.613 [INFO] [myIP:20647-0#example.com] [REWRITE] strip rewrite base: '/' from URI: '/'
2006-06-15 18:00:56.614 [INFO] [myIP:20647-0#example.com] [REWRITE] Rule: Match '' with pattern '^([^.]+)(\.html)?$', result: -1
And if there is no website set:

2006-06-15 18:02:26.268 [INFO] [myIP:20656-0#example.com] [REWRITE] Rule: Match '/' with pattern '^/(.*)$', result: 2
2006-06-15 18:02:26.268 [INFO] [myIP:20656-0#example.com] [REWRITE] Cond: Match 'sesesese.example.com' with pattern '^www\.example\.com$', result: -1
2006-06-15 18:02:26.268 [INFO] [myIP:20656-0#example.com] [REWRITE] Cond: Match 'sesesese.example.com' with pattern '^(www\.)?([a-z-]+)\.example\.com$', result: 3
2006-06-15 18:02:26.268 [INFO] [myIP:20656-0#example.com] [REWRITE] Source URI: '/' => Result URI: '/home/examplepl/public_html/sesesese/'
2006-06-15 18:02:26.291 [INFO] [myIP:20656-0#example.com] [REWRITE] strip rewrite base: '/' from URI: '/'
2006-06-15 18:02:26.291 [INFO] [myIP:20656-0#example.com] [REWRITE] Rule: Match '' with pattern '^([^.]+)(\.html)?$', result: -1
2006-06-15 18:02:26.291 [INFO] [myIP:20656-0#example.com] File not found [/home/examplepl/public_html/sesesese/]
2006-06-15 18:02:26.291 [ERROR] [myIP:20656-0#example.com] detect loop redirection.
Customized Error Pages:
404 Not Found http://example.com/index.html
 

mistwang

LiteSpeed Staff
#6
The problem is that LSWS cannot found the file used for the error page under the missing subdomain. So it reports "detect loop redirection". You can add a static context /index.html pointing to /home/examplecom/public_html/index.html to fix it.
 
Top