Please make sure to update to WPML 4.3.6 and check our list of Known Issues before reporting

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This thread is resolved. Here is a description of the problem and solution.

Problem:.htaccess is rewritten with language folde

Solution:The plugin called "Custom Post Type UI" was triggering this issue. When the plugin is deactivated, the .htaccess file is not rewritten.


This topic contains 6 replies, has 2 voices.

Last updated by cookingwithdog 1 year, 4 months ago.

Assigned support staff: Ricardo Alday.

Author Posts
October 10, 2018 at 5:36 pm #2805327


I recently moved to a new hosting company (SiteGround) and encountered this issue.

The provided snippet was added to functions.php of the child theme for a temporary fix. I suspect "SG Optimizer" is related to this issue since it is the only new plugin added to WordPress, and I found 2 tickets mentioning "SG Optimizer" and ".htaccess".

.htaccess seem to be rewritten when the plugin's Memcached Settings is turned on but I am not sure what exactly triggers the issue. One of the support staff at SiteGround told he disabled SG Optimizer but a few minutes afterward "/ja" was added to .htaccess.

I couldn't replicate the issue on a staging site or on another company's server. I honestly don't want to replicate this on the live site because all the posts and pages start to return 500 error.

Do you have any information about SG Optimizer and this issue?


October 11, 2018 at 3:01 pm #2808795

Ricardo Alday


Thanks for contacting WPML support.
If I understand correctly, you have already deactivated the "SG Optimizer" plugin. In that case, if you rename the htaccess file so that the server creates a new one, does the issue occur again?

October 11, 2018 at 3:52 pm #2809043



Thank you for the reply.

SG Optimizer is active now, and both Dynamic Cache and Memcached are ON with the provided snippet added to functions.php. The snippet is preventing the issue.

If the snippet is removed, "/ja" is added to .htaccess and all the posts and pages get 500 error.

Curiously, "/ja" is NOT added to .htaccess. when Memcached is turned OFF even if the snippet is removed.

As WPML's article noted, the snippet is a temporary fix.

SG Optimizer significantly improves the site performance so I don't want to disable it.

> if you rename the htaccess file so that the server creates a new one

Sorry, I didn't understand this part.

Let me know if you have any questions.


Sorry. The following statement was NOT true. My misunderstanding.
> I can't save the codes of Ad Inserter Pro, an ad managing plugin. I think the snippet of functions.php is interfering with the plugin.

October 11, 2018 at 6:07 pm #2809428

Ricardo Alday

Got it. As stated in our errata page: "The proper fix is for the third-party plugin to flush the rewrite rules only once. This would result in better performance of plugins in question because flushing rewrite rules is a server-expensive operation and extra care should be taken."

I recommend you just keep the snippet since you can confirm it does the job. You can implement the snippet using a plugin called "Code Snippets": instead of using your theme's functions.php file.

That way the snippet will remain active if you update your theme or switch to a different theme.

October 12, 2018 at 2:59 pm #2812360


Code Snippets seems to be very helpful! Thank you so much.

I am going to ask the support staff of the hosting company to check if their cache plugin is actually triggering this issue. Is it OK for you to keep this ticket open until I get back to you with their opinion?

October 12, 2018 at 4:24 pm #2812608

Ricardo Alday

Sure. I'll leave the ticket open. If it happens to close before you can reply just open a new ticket and reference this ticket url.

October 19, 2018 at 1:00 am #2829888


I am almost certain that the plugin called "Custom Post Type UI" was triggering this issue. When the plugin is deactivated, the .htaccess file is not rewritten. SG Optimizer was not related to this problem.

"Toolset Types" seems to be able to create custom post types so I will switch to your plugin.

I found the following comment about flush_rewrite_rules in the "Custom Post Type UI" plugin.

> Wise men say that you should not do flush_rewrite_rules on init or admin_init. Due to the nature of our plugin and how new post types or taxonomies can suddenly be introduced, we need to...potentially. For this, we rely on a short lived transient. Only 5 minutes life span. If it exists, we do a soft flush before deleting the transient to prevent subsequent flushes. The only times the transient gets created, is if post types or taxonomies are created, updated, deleted, or imported. Any other time and this condition should not be met.

Anyway, my issue was resolved. Thank you for your support!