WebP Replacement not working after moving media folder path to subdomain




Wordpress LScache Plugin: WebP Replacement not working after moving media folder path to subdomain

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi, As the title says, Ive decided to move media upload path and existing images to the subdomain. I saw this as a solution to Pingdoms page performance suggestion Use cookie-free domains . However, after I moved the images to the subdomain, everything is expected and fine except that LSCache isnt replacing images with WebP format. The same is with already existing images and new uploads. I tried with a new image upload, it generates WebP variant, but it doesnt serve it on the page. I suppose LSCaches .htaccess rules cannot get reflected to subdomain. Are you familiar with this? Any solution? If you need more info from me just say so. please try go to CDN page , CDN URL and origin URL , both set to your new subdomain (dont miss / at beginning and end , please do carefully follow the tooltip below these 2 options.), and only put image extension in the replace list , save and purge all , see if it helps Hey, thanks for the support, but no success. Actually, Ive already tried all that. Only this time Ive set the image extensions only, while previously Ive just deleted the .css and .js ext. Heres the dropbox folder with screenshots. Accessing the live site will show the old config with normal wp media upload, since I reconnected the old database. I.e. looking into the source will show the normal image path. However, you can see all from screenshots ?Images are loading from the subdomain, LS is generating the Webp for a new img, but it isnt serving it on the actual page. Let me know if theres anything else to try. Thanks. is new image URL retaining the same path ? like domain.com/wp-content/uploads/2022/02/something.jpg to be other.domain.com/wp-content/uploads/2022/02/something.jpg ? or the structure has changed ? Hi, Its been changed. Instead of the wp-content/uploads the folder used is wp . You can see that in the screenshots Ive provided in the previous post. Let me know should I try with reversing it to the wp-content/uploads and is that the only thing to change. whats the full path for new URL ? other.domain.com/wp/wp-content/uploads/2022/02/something.jpg like this ? Hey, its set like this: other.domain.com/wp/2022/02/something.jpg wp is replacing the default wp-content/uploads folder. Theres also a link, in the above post, to the screenshots where-from you can see all that. Let me know what can I try. please : try file type to image only , extension list remove all other non-images ones CDN URL to : https://other.domain.com/wp/ origin URL to: //domain.com/wp-content/uploads/ or //www.domain.com/wp-content/uploads/ Included Directories to : wp-content/uploads/ save and purge all Hi, no success again. Heres the screenshot so you can confirm the saved settings. The issue is the same. It doesnt serve the images as webp on the actual page. Ive tried with uploading a new image. LS creates the webp version, but it isnt serving it on the page, .png is served. Thanks for all your efforts. If you have more suggestions, Im willing to try further. actually I have an idea what went wrong but is this subdomain on same server as main server ? also please enable debug log , it will tell what happened during the webp replacement I think it failed to found the proper file path for webp so it thinks the webp didnt exist therefore not to replace it Hi, yes the subdomain is on the same server as the main domain. However, its completely separate Website instance with its own path and thats where the culprit may be. So lets analyze the debug logs? I could pull the whole log, but this is what were looking for: 10/06/22 11:41:38.680 [185.228.26.40:37494 1 jKt] [Media] webp replacing: https://med.maxpressy.com/wp/2021/08/scrollr-my-section-768x296.png 10/06/22 11:41:38.680 [185.228.26.40:37494 1 jKt] [Util] file not exist: /home/myusername/public_html/wp/2021/08/scrollr-my-section-768x296.png You see, it isnt replacing the .png with its webp because it is looking into the wrong path: /home/myusername/public_html/wp/ instead it should look into this path: /home/med/public_html/wp/ Though the aforementioned is clear to me, I still do not know how to configure the LS to look into the correct path. Ive tried a couple of modifications but no success, it always looks into the default path. I hope you can get it. Let me know what you think. its from here https://github.com/litespeedtech/lscache_wp/blob/6c95240003b89ef1d4ce190f5a96eba83528cd89/src/utility.cls.php#L784 if ( defined( LITESPEED_WP_REALPATH ) ) $file_path_ori = $_SERVER[ DOCUMENT_ROOT ] . LITESPEED_WP_REALPATH . $url_parsed[ path ] but actually I dont think there is a way to do it without modify the plugins source code I have a dirty workaround if the subdomain is not on any CDN service RewriteCond % HTTP_ACCEPT image/webp RewriteCond % REQUEST_FILENAME .webp -f RewriteRule ^(. ).(jpg|jpeg|png|gif) $1.$2.webp [T=image/webp,L] add this to wp-content/uploads/.htaccess it will load webp format under the hood while the URI is remain same as .jpg , if browser supports webp and webp exists , but the content type will be webp and size is reduced I think Ill skip on this for now. Too much tinkering for me in this moment. If I decide to try with this later on, Ill update here. Thanks!



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference