Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Last revision Both sides next revision | ||
litespeed_wiki:troubleshooting:rewrite_difference_on_l_flag_between_lsws_and_apache [2019/01/03 20:39] Jackson Zhang |
litespeed_wiki:troubleshooting:rewrite_difference_on_l_flag_between_lsws_and_apache [2019/01/03 21:04] Lisa Clarke Proofreading |
||
---|---|---|---|
Line 16: | Line 16: | ||
Changing the ruleset order may resolve the issue. | Changing the ruleset order may resolve the issue. | ||
- | Another tip is to use only one ''[L]'' in your ruleset instead of multiple ''[L]''s. | + | Try using 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. | 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. | ||
Line 22: | Line 22: | ||
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. | 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: Change the Order of Rules ==== |
- | For example: | + | Let's say you have this for Apache: |
RewriteEngine On | RewriteEngine On | ||
Line 41: | Line 41: | ||
RewriteRule ^([^\.]+)$ $1.php [NC,L] | RewriteRule ^([^\.]+)$ $1.php [NC,L] | ||
- | ==== Example 2: modify the rules to use only one [L] instead of multi [L]s ==== | + | ==== Example 2: Use Only One [L] Instead of Multiple ==== |
- | For example: | + | Let's say you have this ruleset: |
RewriteEngine On | RewriteEngine On | ||
Line 50: | Line 50: | ||
RewriteRule ^reservar\.html(.*)$ reservar.php [L] | RewriteRule ^reservar\.html(.*)$ reservar.php [L] | ||
| | ||
- | For Apache, it will: | + | Under Apache: |
- | 1- A visitor hits the URL ''http://example.com/es/reservar.html'' . | + | - 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. | + | - The web server recognizes the pattern ''^es/(.*)$'' from the first rewrite rule and the request is internally redirected to ''/reservar.html''. |
- | 3- /reservar.html also matches the rule ^reservar\.html(.*)$ and should be properly redirected to reservar.php. | + | - ''/reservar.html'' also matches the rule ''^reservar\.html(.*)$'' and is redirected to ''reservar.php''. |
- | 4- The content of this latest file should be sent to the visitor. | + | - The contents of this latest file (''reservar.php'') is sent to the visitor. |
- | For LSWS, it will stop at first [L] ''RewriteRule ^es/(.*)$ /$1 [L]'' and doesn't processs the forth line at all. | + | Under LiteSpeed Web Server: |
+ | - A visitor hits the URL ''http://example.com/es/reservar.html'' . | ||
+ | - The web server recognizes the pattern ''^es/(.*)$'' from the first rewrite rule and the request is internally redirected to ''/reservar.html''. | ||
+ | - Processing stops at the first [L] (''RewriteRule ^es/(.*)$ /$1 [L]'') and never reaches 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: | + | If you want LSWS to process these rules with the same results as Apache, you can update them to use only one [L]: |
RewriteEngine On | RewriteEngine On | ||
Line 65: | Line 68: | ||
RewriteRule ^/es/reservar.html(.*)$ reservar.php [L] | RewriteRule ^/es/reservar.html(.*)$ reservar.php [L] | ||
- | ==== Example 3: use ''<IfModule litespeed> ... </IfModule>'' for different rules==== | + | ==== Example 3: Use "<IfModule litespeed> ... </IfModule>" for Different Rules==== |
- | For example: | + | Change this: |
RewriteCond %{REQUEST_URI} !\..* | RewriteCond %{REQUEST_URI} !\..* | ||
Line 91: | Line 94: | ||
RewriteRule (.*) http://example.com/$1 [R=301,L] | RewriteRule (.*) http://example.com/$1 [R=301,L] | ||
- | You can change it to: | + | To this: |
RewriteCond %{REQUEST_URI} !\..* | RewriteCond %{REQUEST_URI} !\..* | ||
Line 136: | Line 139: | ||
</IfModule> | </IfModule> | ||
- | ==== Example 4: use ''<IfModule litespeed> ... </IfModule>'' for different blocks==== | + | ==== Example 4: Use "<IfModule litespeed> ... </IfModule>" for Different Blocks==== |
- | Another example is: | + | Change this: |
RewriteEngine On | RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} -f | RewriteCond %{REQUEST_FILENAME} -f | ||
Line 148: | Line 151: | ||
RewriteRule ^(specials|about_us|links|order_complete|view_cart|checkout).html$ $1.page [L,QSA] | RewriteRule ^(specials|about_us|links|order_complete|view_cart|checkout).html$ $1.page [L,QSA] | ||
| | ||
- | You can make changes like the following: | + | To this: |
<IfModule !litespeed> | <IfModule !litespeed> | ||
RewriteEngine On | RewriteEngine On |