lscache_wp icon indicating copy to clipboard operation
lscache_wp copied to clipboard

Editing wrong .htaccess when site and WP address differ

Open steverep opened this issue 7 years ago • 4 comments

The plugin is editing the .htaccess file at the Wordpress installation address instead of the actual website address. For example, if WP is installed to a subdirectory called "blog", the plugin is writing to "public_html/blog/.htaccess" even though the site address is one directory up. This then results in a nonsensical rule like:

RewriteRule blog/wp-content/...

This is incorrect because the rewrite base defaults to the directory where the .htaccess file resides. I'm getting response headers of:

x-litespeed-cache: miss

When I copy the block to the correct file, I get Hit as expected.

steverep avatar Jan 31 '18 02:01 steverep

Couldn't immediately find in the code where this is going wrong (confused by the frontend and backend variables). In any case, I'd suggest making use of the WP home_url() function for determining the correct .htaccess to write to, and then using the WP content_url() function when forming the RewriteRule in case someone has relocated that directory.

steverep avatar Jan 31 '18 05:01 steverep

On second thought, you could use the get_home_path() function:

$htaccessFile = get_home_path() . '.htaccess'

This function returns the path without the subfolder as desired.

steverep avatar Jan 31 '18 17:01 steverep

Hi! It seems that this issue is still not fixed. I am having the problem on my non default WP setups. Is there any idea when this will be fixed?

herbie4 avatar Jul 06 '20 12:07 herbie4

Looking around in the LS cache plugin settings I found the option for setting the correct path. Great.

.htaccess Path Settings – the auto detect should work fine. Specifying the path is usually not necessary unless you have your site in some non-standard directory or using non-standard htaccess file name.

@steverep It looks like you can close this issue.

herbie4 avatar Jul 06 '20 14:07 herbie4