[Plugin: WP Super Cache] How to get mod_rewrite working on 1and1 shared hosting
-
Hi, here’s what I’ve had to change to get mod_rewrite mode working on 1and1. They seem to have something weird in their configuration that means the document_root values aren’t consistent between PHP and the .htaccess file. The comment in the code should explain what is going on.
function wpsc_get_htaccess_info() { global $wp_cache_mobile_enabled, $wp_cache_mobile_prefixes, $wp_cache_mobile_browsers; if ( isset( $_SERVER[ "PHP_DOCUMENT_ROOT" ] ) ) { $document_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; $apache_root = $_SERVER[ "PHP_DOCUMENT_ROOT" ]; } else { $document_root = $_SERVER[ "DOCUMENT_ROOT" ]; $apache_root = '%{DOCUMENT_ROOT}'; } $home_path = get_home_path(); $content_dir_root = $document_root; if ( strpos( $home_path, '/kunden/' ) === 0 ){ // When WordPress is running on 1and1 shared hosting the home_path // starts with /kunden/, however the WP_CONTENT_DIR does not. // Neither does the .htaccess %{DOCUMENT_ROOT} variable. // This prevents the $inst_root from being calculated correctly and // means that the $apache_root is wrong. // // e.g. This is an example of what these values look like on 1and1: // $home_path: /kunden/homepages/xx/dxxxxxxxx/htdocs/site1/ // WP_CONTENT_DIR: /homepages/xx/dxxxxxxxx/htdocs/site1/blog/wp-content // Here we fix up the paths to make mode_rewrite work on 1and1 shared hosting. $content_dir_root = preg_replace( '/\/kunden\//', '/', $content_dir_root, 1 ); $apache_root = $document_root; } $inst_root = str_replace( '//', '/', '/' . trailingslashit( str_replace( $content_dir_root, '', str_replace( '\\', '/', WP_CONTENT_DIR ) ) ) ); $home_root = parse_url(get_bloginfo('url')); $home_root = isset( $home_root['path'] ) ? trailingslashit( $home_root['path'] ) : '/'; $wprules = implode( "\n", extract_from_markers( $home_path.'.htaccess', 'WordPress' ) ); $wprules = str_replace( "RewriteEngine On\n", '', $wprules );
Someone did previously report this issue – https://www.ads-software.com/support/topic/wp-super-cache-10381-doesnt-deliver-cached-pages
As 1and1 is one of the largest hosting companies out there I think it is worth making the fastest rules work on it.
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘[Plugin: WP Super Cache] How to get mod_rewrite working on 1and1 shared hosting’ is closed to new replies.