Skip Navigation

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

Problem:
.htaccess file is rebuilt and translation gives too many redirects and 500 internal server errors

Solution:
When you use directory for default language make sure to use a root page as explained in the next document.

Relevant Documentation:
https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/

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 topic contains 2 replies, has 2 voices.

Last updated by Károly Farkas 1 year, 8 months ago.

Assisted by: Subash Chandra Poudel.

Author Posts
June 5, 2023 at 12:57 pm #13771241

Károly Farkas

Hello,
I have a returning issue on one of my sites and I could identify the cause of the problem.

My site has 3 languages, 'hu' (hungarian) by default and handled in directories (eg. "example.com/hu")

the .htaacess file has these automatically generated rules, which causes too many redirects, thus 500 internal server errors.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /hu/
RewriteRule ^index\.php$ - [L]
RewriteRule ^en/wp-login.php /hu/wp-login.php [QSA,L]
RewriteRule ^hu/wp-login.php /hu/wp-login.php [QSA,L]
RewriteRule ^sk/wp-login.php /hu/wp-login.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /hu/index.php [L]
</IfModule>

If I delete the "/hu" prefix from the second parameter of "rewriteRule" lines, the problem does not occur.

So these are the settings, which are manually edited and works ok:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /hu/
RewriteRule ^index\.php$ - [L]
RewriteRule ^en/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^hu/wp-login.php /wp-login.php [QSA,L]
RewriteRule ^sk/wp-login.php /wp-login.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Please help me how can I modify the automatic creation of the .htaccess file, so it is generated right?

June 5, 2023 at 5:34 pm #13773927

Subash Chandra Poudel

Hi there, It looks like you are using directory for default language as well but setting Home URL to hidden link and not using any root page which seems to cause the issue here.

Can you please set both your WordPress Address and Site Address at wp-admin -> Settings -> General to hidden link then use a root page as explained in the following document instead:

https://wpml.org/documentation/getting-started-guide/language-setup/directory-default-language/

If you users to go to /hu/ by default you can setup redirect from the root domain as explained in the document above.

June 6, 2023 at 9:27 am #13777007

Károly Farkas

Hi Subash,

The problem might be caused by the absence of root page, which I didn't set up previously. Now I generated a root page, which is redirected to the main language main page, as described in the document. So far it works ok, I hope it will remain even after an automatic generation of the .htaccess file. Thank you for the help!