LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Go Back   LiteSpeed Support Forums > LiteSpeed Web Server > Install/Configuration > Rewrite Rules Subvert Error Pages

Reply
 
Thread Tools Display Modes
  #1  
Old 10-10-2008, 04:06 PM
wagonlips wagonlips is offline
New Member
 
Join Date: Aug 2008
Posts: 9
Default Rewrite Rules Subvert Error Pages

Hi,

I'm running Litespeed Web Server Standard v3.3.19 and Wordpress 2.6.2, and here are the rewrite rules I have in my Litespeed Virtual Host:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I took them from a previous installation on Apache, and they work, allowing Wordpress's pretty permalinks.

The problem is that absolutely everything is rewritten. Nothing ever goes to 404. Any string at all after the domain is rewritten as a directory, and then Wordpress serves up an empty page for it.

Any ideas? I'm looking at the rewrite logs and can't really make head or tail of it.

Thanks!
Reply With Quote
  #2  
Old 10-11-2008, 07:59 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Does Apache show a 404 page with this rewrite rules?
This rewrite rule will rewrite any missing file to index.php.
Reply With Quote
  #3  
Old 10-13-2008, 12:22 PM
wagonlips wagonlips is offline
New Member
 
Join Date: Aug 2008
Posts: 9
Yes, under Apache any bad URL will cause these rules to serve the custom error page, 404.php which is handled by Wordpress.

Maybe that's the problem? A conflict between Wordpress and Litespeed over who serves the error?

I guess I need to figure out how to tell one of them to lay off.
Reply With Quote
  #4  
Old 10-13-2008, 02:31 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
Quote:
Originally Posted by wagonlips View Post
Yes, under Apache any bad URL will cause these rules to serve the custom error page, 404.php which is handled by Wordpress.
We tried it on a WP installation. it does display the 404 page. But the page does get rewritten to index.php first, then index.php calls wp-content/themes/default/404.php

So, I am not sure what exactly is the cause of the problem, maybe you can try disabling WP-Super Cache, once we identify what is the cause of the problem, we can investigate more. We set WP Super Cache to "Half on".
Reply With Quote
  #5  
Old 10-15-2008, 04:08 PM
wagonlips wagonlips is offline
New Member
 
Join Date: Aug 2008
Posts: 9
I've discovered that the presence of either a percentage sign (%) or a back slash (\) will cause the 404 page to be served, which is interesting if not particularly illuminating to me. Here are some logs:

Code:
# A good URL:
[REWRITE] Rule: Match '/recent-work/' with pattern '.', result: 1
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] Source URI: '/recent-work/' => Result URI: '/index.php'
[REWRITE] Last Rule, stop!

# A bad URL:
[REWRITE] Rule: Match '/recent-work/obviously-not-a-real-url' with pattern '.', result: 1
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] Source URI: '/recent-work/obviously-not-a-real-url' => Result URI: '/index.php'
[REWRITE] Last Rule, stop!
[REWRITE] Rule: Match '/recent-work/obviously-not-a-real-url/' with pattern '.', result: 1
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] Source URI: '/recent-work/obviously-not-a-real-url/' => Result URI: '/index.php'
[REWRITE] Last Rule, stop!
# Rewritten twice, coming back the second time with a trailing slash,
# transforming the bad URL into a directory that doesn't exist.

# A URL with a percentage sign on the end:
[REWRITE] Rule: Match '/recent-work/obviously-not-a-real-url' with pattern '.', result: 1
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] Source URI: '/recent-work/obviously-not-a-real-url' => Result URI: '/index.php'
[REWRITE] Last Rule, stop!
# The percentage sign doesn't show up in the log, but the 404
# was served.

# A URL with a back slash:
[REWRITE] Rule: Match '/recent-work/obviously-not-a-real-url\' with pattern '.', result: 1
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] stat( /opt/lsws/HAMBLOG/html/recent-work ) failed 
[REWRITE] Source URI: '/recent-work/obviously-not-a-real-url\' => Result URI: '/index.php'
[REWRITE] Last Rule, stop!
# The 404 was served.
I guess the thing I find most puzzling is that the logs read pretty much the same regardless of what actually happens: every URL reports "result:1" and "failed" and finally, "=> Result URI: '/index.php'" Is that normal?

Thanks for the help!
Reply With Quote
  #6  
Old 10-16-2008, 10:58 AM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
I think it is normal, do you have any WP plugin other than super cache installed?
Reply With Quote
  #7  
Old 10-16-2008, 11:47 AM
wagonlips wagonlips is offline
New Member
 
Join Date: Aug 2008
Posts: 9
Actually, I hadn't used WP-Super Cache until you mentioned it. So I installed it and played around with the settings (Fully on, half-on, Fully on but without Super Cache, and completely off and deactivated, but it didn't make any difference. Then just now I turned off all plugins and still no change.
Reply With Quote
  #8  
Old 10-16-2008, 02:21 PM
mistwang mistwang is offline
LiteSpeed Staff
 
Join Date: May 2003
Location: New Jersey
Posts: 7,590
I think I probably know what is wrong, you configured the rewrite rule at vhost level, but those are designed to be in .htaccess or at directory/context level.

If you do not want to use .htaccess, you can create "/" context point to the document root of your web site, then add rewrite rule there.
Reply With Quote
  #9  
Old 10-16-2008, 05:09 PM
wagonlips wagonlips is offline
New Member
 
Join Date: Aug 2008
Posts: 9
Yes! You are correct. Creating a root context and adding the rewrite rules there works perfectly. Thank you very much!

I never was able to get the .htaccess file to work, but no need to now.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:09 PM.



- Archive - Top
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.