RewriteBase support?

Discussion in 'Install/Configuration' started by jburks725, Oct 5, 2005.

  1. jburks725

    jburks725 New Member

    I'm working with 2.1.2 (Std) and am setting up WordPress (www.wordpress.org). I'd like to use clean URLs, and WP will auto-generate the Apache rewrite rules to support this. After forcing WP to think I'm using Apache, I can get it to write out to a .htaccess file and would like to copy the rules into the VH settings panel rather than leaving them in .htaccess (I've seen this suggested in several threads).

    I've run into a small snag. LSWS doesn't seem to support the RewriteBase directive and this causes the the RewriteRules to fail unless I modify them manually to include the base in the matching pattern. For example, here is (part of) what WP wrote to my .htaccess:

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    ...RewriteRule ^archives/([0-9]{4})/([^/]+).html/(feed|rdf|rss|rss2|atom)/?$ /index.php?year=$1&name=$2&feed=$3 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([^/]+).html/page/?([0-9]{1,})/?$ /index.php?year=$1&name=$2&paged=$3 [QSA,L]
    RewriteRule ^archives/([0-9]{4})/([^/]+).html(/[0-9]+)?/?$ /index.php?year=$1&name=$2&page=$3 [QSA,L]
    </IfModule>

    Copying these rules into the VH configuration (leaving out the first several lines, up to the first RewriteCond) does not work. I get 404 errors for my Permalinks and the debug log shows that no patterns were matched. I noticed in the logs that the URLs passed into the pattern matcher all started with a /, so I modified one of the above rules to the following:

    RewriteRule ^/archives/([0-9]{4})/([^/]+).html/page/?([0-9]{1,})/?$ /index.php?year=$1&name=$2&paged=$3 [QSA,L]

    Notice the leading slash at the beginning of the regex (^/arc... instead of ^arc...). This works--the pattern matches and the URL is rewritten correctly.

    Given this information, and the fact that trying to put the "RewriteBase /" directive in the VH config seems to disable rewriting altogether, I'm left with the following options:

    1) Leave the rewrite rules in .htaccess
    2) Manually edit all of the RewriteRule lines to start the regex with /

    Neither of these is particularly appealing as I'd like to "do the LSWS thing" and put the rewrite rules where they belong, in the VH configuration.

    Please advise how I should proceed. Am I missing something where RewriteBase is supported? If RewriteBase is not supported, do you plan to add it?

    Thanks,
    Jason

    P.S. - I love the server. So much nicer to work with than Apache and lighttpd. Still working on getting everything running, but so far everything looks great. Keep up the good work!
  2. mistwang

    mistwang LiteSpeed Staff

    Hi Jason,

    Thank you for trying our product.

    RewriteBase is only effective for per-directory rewrites, and ignored by vhost level rewrites.

    There is one work around, instead of adding those rewrite rules to vhost level, you can create a static context with URI set to "/" and path to the document root, then add those rewrite rules under that context, RewriteBase should work then. Actually, it is not necessary for LSWS in most case. :)

    George Wang

Share This Page