Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
litespeed_wiki:troubleshooting:rewrite_difference_on_l_flag_between_lsws_and_apache [2019/01/03 20:25]
Jackson Zhang
litespeed_wiki:troubleshooting:rewrite_difference_on_l_flag_between_lsws_and_apache [2019/01/03 20:39]
Jackson Zhang
Line 12: Line 12:
  
 You may need to tweak your Apache rule set to work with LiteSpeed. You may need to tweak your Apache rule set to work with LiteSpeed.
 +
 +==== Tips ====
 +Changing the ruleset order may resolve the issue.
 +
 +Another tip is to use only one ''​[L]''​ in your ruleset instead of multiple ''​[L]''​s.
 +
 +Sometimes the situation may be more complicated. The user may have some rules inherited from an older Apache version, such as Apache 2.2, with a lot of ''​[L]''​s. It may not be easy to make it work for both Apache and LiteSpeed at the same time by simply changing the rule order or removing some ''​[L]''​s. You may try to make the ruleset work for LiteSpeed, but that may break it for Apache. In such cases, we would recommend leaving the Apache ruleset untouched, and enclose it with ''<​IfModule !litespeed>​ ... </​IfModule>''​. Then create a new ruleset for LSWS enclosed with ''<​IfModule litespeed>​ ... </​IfModule>''​ as a workable alternative.
 +
 +Writing rewrite rules may require a deep understanding of how the rewrite engine works and a talent for coding. The end user's rule may be complicated. They may have inherited a lengthy ruleset from a legacy Apache version, or maybe they are not following best practices, or perhaps they even involve some mistake. The final goal is to tweak the existing rules set to work with both LiteSpeed and Apache as quickly as possible, and not to worry about converting the ruleset into a piece of art.  ​
  
 ==== Example 1: Changing the order of rules ==== ==== Example 1: Changing the order of rules ====
Line 32: Line 41:
   RewriteRule ^([^\.]+)$ $1.php [NC,​L] ​   ​   RewriteRule ^([^\.]+)$ $1.php [NC,​L] ​   ​
  
-==== Tipsuse only one [L] or use ''<​IfModule litespeed>​ ... </​IfModule>''​ ==== +==== Example 2modify the rules to use only one [L] instead of multi [L]s ====
-Another tip is to use only one ''​[L]''​ in your ruleset ​instead of multiple ''​[L]''​s.+
  
-Sometimes the situation may be more complicated. The user may have some rules inherited from an older Apache version, such as Apache 2.2, with a lot of ''​[L]''​s. It may not be easy to make it work for both Apache and LiteSpeed at the same time by simply changing the rule order or removing some ''​[L]''​s. You may try to make the ruleset work for LiteSpeed, but that may break it for Apache. In such cases, we would recommend leaving the Apache ruleset untouched, and enclose it with ''<​IfModule !litespeed>​ ... </​IfModule>''​. Then create a new ruleset for LSWS enclosed with ''<​IfModule litespeed>​ ... </​IfModule>''​ as a workable alternative.+For example: ​
  
-Writing rewrite rules may require a deep understanding of how the rewrite ​engine works and a talent for codingThe end user'​s ​rule may be complicatedThey may have inherited a lengthy ruleset from a legacy Apache version, or maybe they are not following best practices, or perhaps they even involve some mistake. The final goal is to tweak the existing rules set to work with both LiteSpeed and Apache as quickly as possible, and not to worry about converting ​the ruleset into a piece of art.  ​+  RewriteEngine On 
 +  RewriteBase / 
 +  RewriteRule ^es/(.*)$ /$1 [L] 
 +  RewriteRule ^reservar\.html(.*)$ reservar.php [L] 
 +   
 +For Apache, it will: 
 +  1- A visitor hits the URL ''​http://​example.com/​es/​reservar.html''​ . 
 +  2- The web server should recognize the pattern ^es/(.*)$ from the first rewrite ​rule and the request should be internally redirected to /reservar.html. 
 +  3- /​reservar.html also matches the rule ^reservar\.html(.*)$ and should ​be properly redirected to reservar.php. 
 +  4- The content of this latest file should be sent to the visitor. 
 + 
 +For LSWSit will stop at first [L] ''​RewriteRule ^es/(.*)$ /$1 [L]'' ​and doesn'​t processs ​the forth line at all. 
 + 
 +You can make the rules reworking as the following by using only one [L] instead ​of multi [L]s to work with LSWS: 
 + 
 +  RewriteEngine On 
 +  RewriteBase / 
 +  RewriteRule ^es/(.*)$ /es/$1 [NC] 
 +  RewriteRule ^/​es/​reservar.html(.*)$ reservar.php [L]
  
-==== Example ​2: use ''<​IfModule litespeed>​ ... </​IfModule>''​ ==== +==== Example ​3: use ''<​IfModule litespeed>​ ... </​IfModule>'' ​for different rules==== 
 For example: For example:
  
Line 110: Line 136:
   </​IfModule>​   </​IfModule>​
  
-==== Example ​3: use ''<​IfModule litespeed>​ ... </​IfModule>''​ ====   +==== Example ​4: use ''<​IfModule litespeed>​ ... </​IfModule>'' ​for different blocks====   
 Another example is: Another example is:
   RewriteEngine On   RewriteEngine On
  • Admin
  • Last modified: 2019/03/19 15:32
  • by Lisa Clarke