Configuring WordPress Permalinks on Lighttpd
To enable WordPress permalinks on a Lighttpd server, you must configure the url.rewrite-once rules. The following optimized rule set correctly handles WordPress core files, static assets, and multisite requests.
Standard Rewrite Rules
Add these rules to your Lighttpd configuration file (typically lighttpd.conf) or the relevant virtual host configuration.
url.rewrite-once = (
"^/(wp-.+)" => "$1",
"^/([_0-9a-zA-Z-]+/)?(wp-.+)" => "$2",
"^/([_0-9a-zA-Z-]+/)?(.*\.php)$" => "$2",
"^/.+\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)(\?.*)?$" => "$0",
"^/(.*)?/?files/(.*)" => "wp-includes/ms-files.php?file=$2",
"(.+)/?$" => "/index.php$1"
)
Rule Explanation and Improvements
This rule set includes several important corrections and optimizations:
- Fixed Syntax Error: The final catch-all rule uses the correct pattern
"(.+)/?$" => "/index.php$1"to pass all other requests toindex.php. - Updated Multisite File Handling: For WordPress Multisite uploads, the correct endpoint is
wp-includes/ms-files.php, not the outdatedwp-content/blogs.php. - Excluded Static Resources: A new rule directly serves static files (CSS, JS, images, fonts) to avoid unnecessary rewriting and improve performance.
- Optimized Core Request Matching: Rules prioritize direct access to WordPress core files (those starting with
wp-).
Configuration Steps
- Back up your Lighttpd configuration file.
- Ensure the
mod_rewritemodule is enabled in your configuration. - Add the
url.rewrite-oncerules provided above. - Reload or restart the Lighttpd service.
- In your WordPress admin panel, go to Settings > Permalinks, choose your preferred structure, and save.
Note: These rules work for standard and multisite WordPress installations. After configuration, verify that your site's front-end, admin area, and media files load correctly.