{"id":15327970,"date":"2024-02-21T13:01:27","date_gmt":"2024-02-21T13:01:27","guid":{"rendered":"https:\/\/wpml.org\/?post_type=faq&#038;p=15327970"},"modified":"2024-02-21T13:01:33","modified_gmt":"2024-02-21T13:01:33","slug":"why-is-htaccess-getting-overwritten-with-the-language-folder-on-my-wpml-website","status":"publish","type":"faq","link":"https:\/\/wpml.org\/zh-hans\/faq\/why-is-htaccess-getting-overwritten-with-the-language-folder-on-my-wpml-website\/","title":{"rendered":"Why is .htaccess getting overwritten with the language folder on my WPML website?"},"content":{"rendered":"\n<p class=\"lead\">Sometimes, third-party plugins call the <strong>flush_rewrite_rules(true)<\/strong> function too often. This leads to changes in the rewrite rules in your <strong>.htaccess <\/strong>file, which can cause issues on your WordPress site.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is the flush_rewrite_rules(true) function and what happens when plugins call it too often?<\/h2>\n\n\n\n<p>The <strong>flush_rewrite_rules(true)<\/strong> function in WordPress is used to regenerate rewrite rules, which are rules that tell your website how to handle URLs. It&#8217;s a critical function but when used too often, it can cause WordPress to overwrite the<strong> .htaccess<\/strong> file.&nbsp;<\/p>\n\n\n\n<p>This becomes problematic when it occurs during every page request or while you browse your site in another language. When this happens, WPML goes ahead and adds the language folder to<strong> home_url <\/strong>as usual. However, this results in an incorrect <strong>RewriteBase<\/strong> in <strong>.htaccess<\/strong>, causing your website&#8217;s front-end to break.&nbsp;<\/p>\n\n\n\n<p>In this case, WPML is acting correctly and the problem is entirely in the plugin calling this function too often.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How can I identify the plugin causing this and fix the issue?<\/h2>\n\n\n\n<p>Identifying the specific plugin causing this issue can be challenging. It involves testing in a minimal environment and deactivating plugins one by one. After finding the responsible plugin, you would need to contact the author and request that they add a fix that limits the rewrite rule flushing to happen only once.&nbsp;<\/p>\n\n\n\n<p>As a quick workaround, you can instruct WPML not to add the language folder. To do this, add the following code to your theme&#8217;s <strong>functions.php<\/strong> file:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nadd_filter(&#039;mod_rewrite_rules&#039;, &#039;fix_rewritebase&#039;);\nfunction fix_rewritebase($rules){\n    $home_root = parse_url(home_url());\n    if ( isset( $home_root&#x5B;&#039;path&#039;] ) ) {\n        $home_root = trailingslashit($home_root&#x5B;&#039;path&#039;]);\n    } else {\n        $home_root = &#039;\/&#039;;\n    }\n \n    $wpml_root = parse_url(get_option(&#039;home&#039;));\n    if ( isset( $wpml_root&#x5B;&#039;path&#039;] ) ) {\n        $wpml_root = trailingslashit($wpml_root&#x5B;&#039;path&#039;]);\n    } else {\n        $wpml_root = &#039;\/&#039;;\n    }\n \n    $rules = str_replace(&quot;RewriteBase $home_root&quot;, &quot;RewriteBase $wpml_root&quot;, $rules);\n    $rules = str_replace(&quot;RewriteRule . $home_root&quot;, &quot;RewriteRule . $wpml_root&quot;, $rules);\n \n    return $rules;\n}\n\n<\/pre><\/div>\n\n\n<h2 class=\"wp-block-heading\">What should I do if I need more help?<\/h2>\n\n\n\n<p>If you continue to face problems or need specific assistance, please <a href=\"https:\/\/wpml.org\/forums\/forum\/english-support\/\">contact our support team<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes, third-party plugins call the flush_rewrite_r [&hellip;]<\/p>\n","protected":false},"author":538393,"featured_media":0,"menu_order":11,"template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_uag_custom_page_level_css":"","ep_exclude_from_search":false,"footnotes":""},"faq-category":[26133],"class_list":["post-15327970","faq","type-faq","status-publish","hentry","faq-category-troubleshooting"],"spectra_custom_meta":{"_subscription_coupon_product_id":["0"],"_wpv_contains_gutenberg_views":[""],"_edit_lock":["1711113402:538393"],"_wpml_word_count":["395"],"_alp_processed":["1708520494"],"_edit_last":["538393"],"faq_order":["6"],"wpcf-faq-category":["5"],"_wpml_media_duplicate":["1"],"_wpml_media_featured":["1"],"_yoast_wpseo_primary_faq-category":["26133"],"_yoast_wpseo_content_score":["90"],"_yoast_wpseo_estimated-reading-time-minutes":[""],"_yoast_wpseo_wordproof_timestamp":[""],"_wpml_location_migration_done":["1"],"_views_template":["0"],"_oembed_d45e48e1af800662f1092912cdfb3725":["<iframe title=\"WPML Translation Manager Role\" width=\"700\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/zKax_E3jRB0?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_d45e48e1af800662f1092912cdfb3725":["1715874527"],"_oembed_66b65cc4963b02a06397f5195d38724a":["<iframe title=\"WPML New Media Translation\" width=\"700\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/aUTPX7kahUs?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_66b65cc4963b02a06397f5195d38724a":["1715874527"],"_oembed_1a7aa0a619dad47a6cfdae8f8e97e437":["<iframe title=\"How to use the new WPML Advanced Translation Editor\" width=\"700\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/kAaSEpjijhQ?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_1a7aa0a619dad47a6cfdae8f8e97e437":["1715874527"],"_oembed_9596c0d9095e7ce9cc90624324ef4422":["<iframe title=\"Duplicator For WordPress Quick Overview - See Description for UPDATED VERSION.\" width=\"700\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/yZ7pHmR9JC8?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_9596c0d9095e7ce9cc90624324ef4422":["1715874527"],"_oembed_12570cf8030926800bac0f1584e1e153":["<iframe title=\"How to use the backup wizard in cpanel\" width=\"700\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/eS-tCkc-gm0?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_12570cf8030926800bac0f1584e1e153":["1715874527"],"_oembed_1c0ef2e069ab1e666be8a1bac83a42ee":["{{unknown}}"],"_oembed_e9018e6807d31b4505b7ad464275fdce":["<iframe title=\"How to copy multiple accounts from another server to your WHM server using SSH\" width=\"525\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/C6ro9h0qowU?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_e9018e6807d31b4505b7ad464275fdce":["1715874527"],"_oembed_9052213bd50132682bbabb79e50bace9":["<iframe title=\"How to use FTP to upload files to WordPress for Beginners\" width=\"700\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/_nDQz1JQfYA?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_9052213bd50132682bbabb79e50bace9":["1715874528"],"_oembed_cfcc8d32f359dd000173b240cccb4392":["{{unknown}}"],"_oembed_c4c4fb99b23e8039596f64010f555d7a":["<iframe title=\"WPML Embedded Installer for Authors\" width=\"525\" height=\"394\" src=\"https:\/\/www.youtube.com\/embed\/vdVNiV8_evQ?feature=oembed&enablejsapi=1&origin=https:\/\/wpml.org\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>"],"_oembed_time_c4c4fb99b23e8039596f64010f555d7a":["1732558155"],"_uag_css_file_name":["uag-css-15327970.css"],"_uag_page_assets":["a:9:{s:3:\"css\";s:260:\".uag-blocks-common-selector{z-index:var(--z-index-desktop) !important}@media(max-width: 976px){.uag-blocks-common-selector{z-index:var(--z-index-tablet) !important}}@media(max-width: 767px){.uag-blocks-common-selector{z-index:var(--z-index-mobile) !important}}\";s:2:\"js\";s:0:\"\";s:18:\"current_block_list\";a:4:{i:0;s:14:\"core\/paragraph\";i:1;s:12:\"core\/heading\";i:2;s:22:\"syntaxhighlighter\/code\";i:3;s:14:\"core\/shortcode\";}s:8:\"uag_flag\";b:0;s:11:\"uag_version\";s:10:\"1778122249\";s:6:\"gfonts\";a:0:{}s:10:\"gfonts_url\";s:0:\"\";s:12:\"gfonts_files\";a:0:{}s:14:\"uag_faq_layout\";b:0;}"]},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"gform-image-choice-sm":false,"gform-image-choice-md":false,"gform-image-choice-lg":false,"woocommerce_thumbnail":false,"woocommerce_single":false,"woocommerce_gallery_thumbnail":false},"uagb_author_info":{"display_name":"Kathy","author_link":"https:\/\/wpml.org\/zh-hans\/author\/kathy-b\/"},"uagb_comment_info":0,"uagb_excerpt":"Sometimes, third-party plugins call the flush_rewrite_r...","_links":{"self":[{"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/faq\/15327970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/faq"}],"about":[{"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/types\/faq"}],"author":[{"embeddable":true,"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/users\/538393"}],"version-history":[{"count":8,"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/faq\/15327970\/revisions"}],"predecessor-version":[{"id":15328057,"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/faq\/15327970\/revisions\/15328057"}],"wp:attachment":[{"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/media?parent=15327970"}],"wp:term":[{"taxonomy":"faq-category","embeddable":true,"href":"https:\/\/wpml.org\/zh-hans\/wp-json\/wp\/v2\/faq-category?post=15327970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}