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.

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Pieter 4 years, 9 months ago.

Assigned support staff: Joanna.

Author Posts
August 25, 2014 at 8:11 am #456705

Pieter

Language URL Format is set to "Different languages in directories" with the addition to "Use directory for default language". Selected "A page" for the root url where the language switcher is hidden.

All is working fine when visitors type in hidden link: a visitor lands on the root page, where he/she can read a short intro in any of the 5 languages and from there basically choose the language, all cool.

The problem starts when a visitor types hidden link (note the addition of www.). The visitor then is automatically directed to hidden link (English is the default language), which obviously is wrong as the visitor then completely skips the language selection.

So I made a CNAME redirection in cPanel to redirect hidden link to domain.com and although that works fine at first sight, WPML then starts throwing a whole bunch of errors on the backend.

So now I am at the point where I don't know what to do?
I could ignore the errors as everything seems to be working, but will that last?

Is there any other way to redirect www to without www that doesn't impact WPML on the backend?

Looking forward to receiving any input from you guys on this.

Cheers,
Piet

August 25, 2014 at 2:01 pm #457058

Joanna

Hello Piet,

Is your site url and home url set to domain.com (not hidden link)?
What we suggest to do is to "redirect to the canonical host in .htaccess".
See hidden link

Please let me know if that helped.

August 25, 2014 at 2:18 pm #457077

Pieter

Hi Joanna, thanks for your reply.
Yes, both site url and home url are set to domain.com

Thanks for the link, unfortunately now it really become abacadabra for me.

I want hidden link to become domain.com, so according to the examples in your link I then should do this?

<VirtualHost *:80>
  ServerName <em><u>hidden link</u></em>
  ServerAlias domain.com <em><u>hidden link</u></em>

  Redirect / <em><u>hidden link</u></em>
</VirtualHost>

<VirtualHost *:80>
  ServerName domain.com
</VirtualHost>

Before I start royally messing up a live site, can you please have a look whether the above is correct?

Thanks,
Piet

August 25, 2014 at 4:24 pm #457197

Joanna

Hello Piet,

Please try this one:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ <em><u>hidden link</u></em> [R=301,L]
August 25, 2014 at 4:32 pm #457202

Pieter

Well that is the whole point. In my initial request I already wrote that exactly doing that is throwing the errors.

Also the article you linked to, says explicitly that doing it via a rewrite is not necessary and instead says to do it with the

Redirect

.

But because for me it is the first time I hear about Redirect AND you advised me to use it AND the instructions on that site are anything but clear and understandable, I asked you whether you would be able to help me on my way.

So, I'm sorry, but I don't understand why you now tell me to use Rewrite after all (which we already know doesn't work) and completely ignore the Redirect you have just pointed me to in your earlier reply?

August 25, 2014 at 4:43 pm #457210

Pieter

Just tried this:

NameVirtualHost *:80
<VirtualHost *:80>
  ServerName <em><u>hidden link</u></em>
  ServerAlias <em><u>hidden link</u></em>
  Redirect permanent / <em><u>hidden link</u></em>
</VirtualHost>

<VirtualHost *:80>
  # Canonical host
  ServerName community-currency.info
  DocumentRoot /home/ccinfo/public_html
</VirtualHost>

But that immediate throws Internal Server Errors on any domain (www or non-www)

August 26, 2014 at 10:08 am #457618

Joanna

Hello Piet,

I'm sorry about that.
You should find a complete error message in your apache logs. Can you share it with us?

Also, do you have the "mod_alias" apache module enabled‏?

August 26, 2014 at 10:27 am #457630

Pieter

I don't have direct access to apache, I only have cPanel access

August 26, 2014 at 11:07 am #457663

Joanna

Could you please check it with the phpinfo() funtion? The "mod_alias" apache module must be enabled to make the rewrite work, so this could be the problem.

August 26, 2014 at 11:30 am #457682

Pieter

Joanna, let's rewind a bit.

The problem is not that the rewrite doesn't work, it does, very well actually.

The problem is that when I use the 301 permanent redirect the WPML backend shows all kinds of errors that different languages in different directories AND having a page as the root page are not possible.

As soon as I remove the 301 permanent redirect the errors are gone.

My original question was therefore:

1. I can ignore the errors as everything seems to be working, but will that last?

2. Is there any other way to redirect www to without www that doesn't impact WPML on the backend?

Hopefully you understand it now. If not, then please close this ticket, I will then find another channel.

Thanks,
Piet

August 27, 2014 at 8:14 am #458282

Joanna

Hello Piet,

I consulted your case again.

As for your questions:
1. If everything is working fine now, you can ignore the errors. However, we have to investigate it further to make sure that these errors are being displayed incorrectly.
For that, I want to request temporary access (wp-admin and FTP) to your website - preferably to a test site where the problem has been replicated. You will find the fields required for it below the comment area when you log in to leave your next reply. The information you will enter is private, which means only you and I can see and have access to it.
2. Not that we can see.