litespeedtech / litespeedtech/lscache_wp
.htaccess file updated with incorrect host on multisite
- Dominant language
- PHP
- Stars
- 257
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
# Steps to reproduce
1. Setup a domain based multisite on `example.net`
2. Add a new subsite setting `www.example.co.uk`
3. Configure LS Config CSS/JS/Page Cache settings to on.
# Expected result
`.htaccess` file to not mention `www.example.co.uk` perhaps using references to `HTTP_HOST` if absolutely needed but avoid referencing hostname if it can. Not be modified regardless of subsites added / settings changed
# Actual result
`.htaccess` file contains many incorrect references to subsite `www.example.co.uk`
```
# BEGIN NON_LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
### marker Network CSS/JS Auto Generation Rules start ###
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/https://www.example.co.uk/wp-content
RewriteRule ^([_0-9a-zA-Z-]+/)?(https://www.example.co.uk/wp-content/litespeed/cssjs/.*) $2 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/https://www.example.co.uk/wp-content/litespeed/cssjs/.+\.(css|js)$
RewriteRule . /index.php [L]
### marker Network CSS/JS Auto Generation Rules end ###
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
# END NON_LSCACHE
# BEGIN LSCACHE
## LITESPEED WP CACHE PLUGIN - Do not edit the contents of this block! ##
RewriteEngine on
CacheLookup on
RewriteRule .* - [E=Cache-Control:no-autoflush]
RewriteRule \.object-cache\.ini - [F,L]
### marker CACHE RESOURCE start ###
RewriteRule https://www.example.co.uk/wp-content/.*/[^/]*(responsive|css|js|dynamic|loader|fonts)\.php - [E=cache-control:max-age=3600]
### marker CACHE RESOURCE end ###
```
# Notes
The code that seems to be responsible for generating the hostname elements of this is here:
https://github.com/litespeedtech/lscache_wp/blob/1033fc0e8b54d5eb0f87e5946f2b5a68599762f6/src/htaccess.cls.php#L643
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/htaccess.cls.php around line 643 and reproduce the domain-based multisite setup with CSS/JS and page cache enabled. Inspect the generated .htaccess rules for subsite hostnames and compare them with the expected network-safe behavior. Done means adding or changing a subsite no longer inserts incorrect host references into the generated rules.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100