Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide .htaccess changes in the plugin #27

Open
Zodiac1978 opened this issue Jul 7, 2016 · 9 comments
Open

Provide .htaccess changes in the plugin #27

Zodiac1978 opened this issue Jul 7, 2016 · 9 comments

Comments

@Zodiac1978
Copy link
Member

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

@swissspidy swissspidy modified the milestone: 2.3.0 Jul 12, 2016
@swissspidy
Copy link
Contributor

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

@websupporter
Copy link
Contributor

websupporter commented Jan 4, 2017

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

@bueltge bueltge modified the milestones: 2.4.0, 2.3.0 Jan 4, 2017
@Zodiac1978
Copy link
Member Author

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

@websupporter
Copy link
Contributor

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;

@Zodiac1978
Copy link
Member Author

English, please! ;) Nice finding. :)

@timse201
Copy link
Contributor

timse201 commented Jan 26, 2017

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)

@Zodiac1978
Copy link
Member Author

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

@chesio
Copy link
Contributor

chesio commented May 20, 2017

Maybe we should always output the whole path?

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

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

@stklcode
Copy link
Contributor

stklcode commented Aug 12, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants