![]() |
[solved] [makeshift] Apache mod rewrite incompatibility
Currently I use method here in apache
http://stackoverflow.com/questions/6...rule-just-once to prevent multiple or recursive rewrite rule. RewriteCond %{ENV:REDIRECT_STATUS} ^$ It's work great on apache but somehow not work on litespeed. |
Quote:
Quote:
can you give an example rewriterule, which you want it behavior as expected ? |
Test case
Actually I haven't test this yet.
(for now I'm working on apache server.) However, this is a simple test case that I come up with. When I want to allow only specific URI to pass to php script but block everything else. So I write it as Code:
RewriteEngine OnRewriteCond %{ENV:REDIRECT_STATUS} ^$ not work and no other RewriteCond on RewriteRule .* /restricted.php [L] when RewriteRule .* /keygenerator.php executed it also execute RewriteRule .* /restricted.php and when RewriteRule .* /restricted.php executed It go recursive loop with the rule itself. note: I haven't actually test this but I had some rewrite module test (When I found this problem during set up my software on LSWS.) |
I did following tests with lsws, it's working as expected:
Code:
RewriteEngine OnPHP Code:
result: Quote:
result: Quote:
|
Actual test case
Sorry
my bad Now I remembered the situation. I have directory say "abc" in document root Normally if I leave it handle by web server visitor can access it with http://www.example.com/abc/... but I don't want that this is what I want http://www.example.com/!/... Basically I can just rename directory "abc" to "!" but I have good reason to leave it as "abc" in back-end. thus I use rewrite module to handle this first I just rewrite /!/ to /abc/ which pretty simple Code:
<IfModule rewrite_module>http://www.example.com/abc/... then I add some more rewrite rule to make some kind of null route from that URI this is when things mess up Code:
<IfModule rewrite_module>LSWS behave like this: - when people access http://www.example.com/abc/... it drop the request with some dummy file which is correct as my expectation. - when people access http://www.example.com/!/... it also redirect to the dummy file. this code is same for Apache. However in Apache I just put RewriteCond %{ENV:REDIRECT_STATUS} ^$ on each rule but as you know I can't do that on LSWS. Now I have to handle the request with PHP or other server side script which is heavyweight and not a good solution. Probably it may have some other solution but I can't think of good one. |
tested, following rewrite rules meet your requirement:
Quote:
and with %{ORG_REQ_URI}, no need ENV:REDIRECT_STATUS |
Wow
There are very few information about it on the internet. So the equivalent would be Code:
RewriteCond %{REQUEST_URI} =%{ORG_REQ_URI}Now I can solve my problem. However, still the fact that it incompatibility with apache rewrite module. Thus Litespeed is not completely Apache interchangeable since users have to tweak something when working with Litespeed. Anyway, thank you for now. |
it looks like %(ENV:REDIRECT_STATUS} in rewriterule is an undocumented feature in apache. if so, not recommend to use it.
http://httpd.apache.org/docs/current...d_rewrite.html apache 2.3.9, introduced a new rewrite flag "END" Quote:
|
No
No
It is documented in current release of Apache HTTP Server. Quote:
_http://httpd.apache.org/docs/current/custom-error.html However, it not very well document related to rewrite module. |
| All times are GMT -7. The time now is 05:29 PM. |