s $rules = '# Gzip compression' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '# Active compression' . PHP_EOL; $rules .= 'SetOutputFilter DEFLATE' . PHP_EOL; $rules .= '# Force deflate for mangled headers' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding' . PHP_EOL; $rules .= 'RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding' . PHP_EOL; $rules .= '# Don’t compress images and other uncompressible content' . PHP_EOL; $rules .= 'SetEnvIfNoCase Request_URI \\' . PHP_EOL; $rules .= '\\.(?:gif|jpe?g|png|rar|zip|exe|flv|mov|wma|mp3|avi|swf|mp?g|mp4|webm|webp|pdf)$ no-gzip dont-vary' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; $rules .= '# Compress all output labeled with one of the following MIME-types' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'AddOutputFilterByType DEFLATE application/atom+xml \ application/javascript \ application/json \ application/rss+xml \ application/vnd.ms-fontobject \ application/x-font-ttf \ application/xhtml+xml \ application/xml \ font/opentype \ image/svg+xml \ image/x-icon \ text/css \ text/html \ text/plain \ text/x-component \ text/xml' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'Header append Vary: Accept-Encoding' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; /** * Filter rules to improve performances with GZIP Compression * * @since 1.0 * * @param string $rules Rules that will be printed. */ $rules = apply_filters( 'rocket_htaccess_mod_deflate', $rules ); return $rules; } /** * Rules to improve performances with Expires Headers * * @since 1.0 * * @return string $rules Rules that will be printed */ function get_rocket_htaccess_mod_expires() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $rules = << AddType image/avif avif AddType image/avif-sequence avifs # Expires headers (for better cache control) ExpiresActive on ExpiresDefault "access plus 1 month" # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) ExpiresByType text/cache-manifest "access plus 0 seconds" # Your document html ExpiresByType text/html "access plus 0 seconds" # Data ExpiresByType text/xml "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType application/json "access plus 0 seconds" # Feed ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType application/atom+xml "access plus 1 hour" # Favicon (cannot be renamed) ExpiresByType image/x-icon "access plus 1 week" # Media: images, video, audio ExpiresByType image/gif "access plus 4 months" ExpiresByType image/png "access plus 4 months" ExpiresByType image/jpeg "access plus 4 months" ExpiresByType image/webp "access plus 4 months" ExpiresByType video/ogg "access plus 4 months" ExpiresByType audio/ogg "access plus 4 months" ExpiresByType video/mp4 "access plus 4 months" ExpiresByType video/webm "access plus 4 months" ExpiresByType image/avif "access plus 4 months" ExpiresByType image/avif-sequence "access plus 4 months" # HTC files (css3pie) ExpiresByType text/x-component "access plus 1 month" # Webfonts ExpiresByType font/ttf "access plus 4 months" ExpiresByType font/otf "access plus 4 months" ExpiresByType font/woff "access plus 4 months" ExpiresByType font/woff2 "access plus 4 months" ExpiresByType image/svg+xml "access plus 4 months" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" # CSS and JavaScript ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" HTACCESS; /** * Filter rules to improve performances with Expires Headers * * @since 1.0 * * @param string $rules Rules that will be printed. */ $rules = apply_filters( 'rocket_htaccess_mod_expires', $rules ); return $rules; } /** * Rules for default charset on static files * * @since 1.0 * * @return string $rules Rules that will be printed */ function get_rocket_htaccess_charset() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals // Get charset of the blog. $charset = preg_replace( '/[^a-zA-Z0-9_\-\.:]+/', '', get_bloginfo( 'charset', 'display' ) ); if ( empty( $charset ) ) { return ''; } $rules = "# Use $charset encoding for anything served text/plain or text/html" . PHP_EOL; $rules .= "AddDefaultCharset $charset" . PHP_EOL; $rules .= "# Force $charset for a number of file formats" . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= "AddCharset $charset .atom .css .js .json .rss .vtt .xml" . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; /** * Filter rules for default charset on static files * * @since 1.0 * * @param string $rules Rules that will be printed. */ $rules = apply_filters( 'rocket_htaccess_charset', $rules ); return $rules; } /** * Rules for cache control * * @since 1.1.6 * * @return string $rules Rules that will be printed */ function get_rocket_htaccess_files_match() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $rules = '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'Header set X-Powered-By "WP Rocket/' . WP_ROCKET_VERSION . '"' . PHP_EOL; $rules .= 'Header unset Pragma' . PHP_EOL; $rules .= 'Header append Cache-Control "public"' . PHP_EOL; $rules .= 'Header unset Last-Modified' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'Header unset Pragma' . PHP_EOL; $rules .= 'Header append Cache-Control "public"' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; /** * Filter rules for cache control * * @since 1.1.6 * * @param string $rules Rules that will be printed. */ $rules = apply_filters( 'rocket_htaccess_files_match', $rules ); return $rules; } /** * Rules to remove the etag * * @since 1.0 * * @return string $rules Rules that will be printed */ function get_rocket_htaccess_etag() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals $rules = '# FileETag None is not enough for every server.' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'Header unset ETag' . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; $rules .= '# Since we’re sending far-future expires, we don’t need ETags for static content.' . PHP_EOL; $rules .= '# developer.yahoo.com/performance/rules.html#etags' . PHP_EOL; $rules .= 'FileETag None' . PHP_EOL . PHP_EOL; /** * Filter rules to remove the etag * * @since 1.0 * * @param string $rules Rules that will be printed. */ $rules = apply_filters( 'rocket_htaccess_etag', $rules ); return $rules; } /** * Rules to Cross-origin fonts sharing when CDN is used * * @since 2.4 * * @return string $rules Rules that will be printed */ function get_rocket_htaccess_web_fonts_access() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals if ( ! get_rocket_option( 'cdn', false ) ) { return; } $rules = '# Send CORS headers if browsers request them; enabled by default for images.' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '# mod_headers, y u no match by Content-Type?!' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'SetEnvIf Origin ":" IS_CORS' . PHP_EOL; $rules .= 'Header set Access-Control-Allow-Origin "*" env=IS_CORS' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; $rules .= '# Allow access to web fonts from all domains.' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= 'Header set Access-Control-Allow-Origin "*"' . PHP_EOL; $rules .= '' . PHP_EOL; $rules .= '' . PHP_EOL . PHP_EOL; // @codingStandardsIgnoreEnd /** * Filter rules to Cross-origin fonts sharing * * @since 1.0 * * @param string $rules Rules that will be printed. */ $rules = apply_filters( 'rocket_htaccess_web_fonts_access', $rules ); return $rules; } /** * Tell if WP rewrite rules are present in a given string. * * @since 3.2.4 * @author Grégory Viguier * * @param string $content Htaccess content. * @return bool */ function rocket_has_wp_htaccess_rules( $content ) { if ( is_multisite() ) { $has_wp_rules = strpos( $content, '# add a trailing slash to /wp-admin' ) !== false; } else { $has_wp_rules = strpos( $content, '# BEGIN WordPress' ) !== false; } /** * Tell if WP rewrite rules are present in a given string. * * @since 3.2.4 * @author Grégory Viguier * * @param bool $has_wp_rules True when present. False otherwise. * @param string $content .htaccess content. */ return apply_filters( 'rocket_has_wp_htaccess_rules', $has_wp_rules, $content ); } /** * Check if WP Rocket htaccess rules are already present in the file * * @since 3.3.5 * @author Remy Perona * * @return bool */ function rocket_check_htaccess_rules() { if ( ! function_exists( 'get_home_path' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $htaccess_file = get_home_path() . '.htaccess'; if ( ! rocket_direct_filesystem()->is_readable( $htaccess_file ) ) { return false; } $htaccess = rocket_direct_filesystem()->get_contents( $htaccess_file ); if ( preg_match( '/\s*# BEGIN WP Rocket.*# END WP Rocket\s*?/isU', $htaccess ) ) { return true; } return false; } 200-75-119 – تک ظرف