cachify icon indicating copy to clipboard operation
cachify copied to clipboard

Provide .htaccess changes in the plugin

Open Zodiac1978 opened this issue 9 years ago • 9 comments

If the user is using a caching method which needs a change of the .htaccess file, we should provide the code in the plugin itself for copy&paste.

Bonus points if we check if the server is providing correct data for %{DOCUMENT_ROOT} and provide a solution for this problem, see Wiki

Zodiac1978 avatar Jul 07 '16 12:07 Zodiac1978

Even better: Directly write to the .htaccess file. I think WP Simple Cache does this quite well and simple.

swissspidy avatar Aug 17 '16 06:08 swissspidy

Any thoughts here on NGINX. I do not have a lot of experience with it, but how does WordPress handle this in general and do we need something like a Nginx/Apache detection before providing a .htaccess/nginx configuration?

related: https://codex.wordpress.org/Nginx

websupporter avatar Jan 04 '17 08:01 websupporter

If we can detect nginx we should provide (or write) the code for nginx directly.

Zodiac1978 avatar Jan 04 '17 18:01 Zodiac1978

Es gibt wohl eine globale $is_nginx definiert in wp-includes/vars.php

/**
 * Whether the server software is Apache or something else
 * @global bool $is_apache
 */
$is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false);

/**
 * Whether the server software is Nginx or something else
 * @global bool $is_nginx
 */
$is_nginx = (strpos($_SERVER['SERVER_SOFTWARE'], 'nginx') !== false);

/**
 * Whether the server software is IIS or something else
 * @global bool $is_IIS
 */
$is_IIS = !$is_apache && (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false);

/**
 * Whether the server software is IIS 7.X or greater
 * @global bool $is_iis7
 */
$is_iis7 = $is_IIS && intval( substr( $_SERVER['SERVER_SOFTWARE'], strpos( $_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/' ) + 14 ) ) >= 7;

websupporter avatar Jan 05 '17 07:01 websupporter

English, please! ;) Nice finding. :)

Zodiac1978 avatar Jan 07 '17 01:01 Zodiac1978

think we can use both we could add an option to directly write to to config files and if it is not checked an setup tab is displayed

(im working right now on adding these tabs)

timse201 avatar Jan 26 '17 15:01 timse201

According to the %{DOCUMENT_ROOT} problem on some hosters, this is just a problem in .htaccess. Per PHP the variable is still readable. Maybe we should always output the whole path? See: https://gist.github.com/sergejmueller/5501098

Zodiac1978 avatar May 19 '17 12:05 Zodiac1978

Maybe we should always output the whole path?

This is already done since 99b54404e82cd368b54955ebd31655849f597361 via use of WP_CONTENT_DIR.

Btw. what's left to do in this ticket? Directly writing to .htaccess file as @swissspidy suggested?

chesio avatar May 20 '17 15:05 chesio

Directly writing to .htaccess file

That's something I'd personally would not want any plugin to to, at least not automatically. This only works for a single use case:

  • an Apache webserver is used at all
  • the AllowOverride in the server configuration allows the required overrides
  • .htaccess exists and is writable (a reasonable security configuration should prevent the latter)
  • the .htaccess does not contain any unforeseen changes from the default version, otherwise we might run into trouble

In shared environments even showing a modified version of the original .htaccess might leak information the administrator is not intended to see.

stklcode avatar Aug 12 '18 15:08 stklcode