URL trouble since 1.4.4
-
Hi,
I upgraded a client site with 1.4.4, and since then, the website URLs behave strangely and aren’t working anymore.
First my conf :
- 2 languages : FR and EN
- permalinks set to postname
- URL modification is set to different domain per language
When I try to access them (for example http://www.domain.com), they are modified to http://www.domain.comhttp//www.domain.com/, or http://www.domain.comhttp//www.domain.com/contact/ for an internal page. Same for the translated content on en.domain.com
This is not happening for pages that aren’t translated. I tried dev version (1.4.4.2) but it didn’t changed anything.
Downgrading to 1.4.3 fixes the problem, but it’s a temporary solution of course.
-
Could you give me exactly your permalinks setting with % and slashes?
It’s /%postname%/
That’s not something I am able to reproduce.
Can you tell me what you enter as domains in Polylang settings?there is :
English : http://en.domain.com
French : http://www.domain.comI don’t understand what can happen.
in wp-config.php, can you temporarily replace
define('WP_DEBUG', false);
by
define('WP_DEBUG', true); define('SCRIPT_DEBUG', true); define('WP_DEBUG_LOG', true); ini_set('display_errors','Off');
Activate Polylang 1.4.4
And in polylang/frontend/choose-lang-url.php replace
$requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $redirect_url = $this->links_model->remove_language_from_link($requested_url); $redirect_url = $this->links_model->add_language_to_link($redirect_url, $language);
by
$requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; error_log('requested: ' . $requested_url); $redirect_url = $this->links_model->remove_language_from_link($requested_url); error_log('remove lang: ' . $redirect_url); $redirect_url = $this->links_model->add_language_to_link($redirect_url, $language); error_log('add lang: ' . $redirect_url);
Then load a page where you’ve the issue and report the output you get in wp-content/debug.log here.
[13-Apr-2014 16:18:46 UTC] requested: http://www.hotellescygnes.com/contact-plan-acces/ [13-Apr-2014 16:18:46 UTC] remove lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/contact-plan-acces/ [13-Apr-2014 16:18:46 UTC] add lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/contact-plan-acces/ [13-Apr-2014 16:18:50 UTC] requested: http://www.hotellescygnes.com/chambres/ [13-Apr-2014 16:18:50 UTC] remove lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/chambres/ [13-Apr-2014 16:18:50 UTC] add lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/chambres/ [13-Apr-2014 16:18:53 UTC] requested: http://en.hotellescygnes.com/ [13-Apr-2014 16:18:53 UTC] remove lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/ [13-Apr-2014 16:18:53 UTC] add lang: http://en.hotellescygnes.comhttp://en.hotellescygnes.com/ [13-Apr-2014 16:20:14 UTC] requested: http://en.hotellescygnes.com/la-carte-english/ [13-Apr-2014 16:20:14 UTC] remove lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/la-carte-english/ [13-Apr-2014 16:20:14 UTC] add lang: http://en.hotellescygnes.comhttp://en.hotellescygnes.com/la-carte-english/
Well. At least now I know which function is wrong…
Could you go in polylang/include/links-domain.php and replacepublic function remove_language_from_link($url) { if (!empty($this->options['domains'])) $url = preg_replace('#^('.implode('|', $this->options['domains']).')#', $this->home , $url); return $url; }
by
public function remove_language_from_link($url) { error_log('url: '.$url); error_log(print_r($this->options['domains'], true)); error_log('pattern: ' . '#^('.implode('|', $this->options['domains']).')#'); error_log('home: '. $this->home); error_log('opt: ' . get_option('home')); if (!empty($this->options['domains'])) $url = preg_replace('#^('.implode('|', $this->options['domains']).')#', $this->home , $url); return $url; }
NB: You should keep the debug mode to do this.
[13-Apr-2014 18:46:47 UTC] requested: http://en.hotellescygnes.com/hotel-services-amenities/ [13-Apr-2014 18:46:47 UTC] url: http://en.hotellescygnes.com/hotel-services-amenities/ [13-Apr-2014 18:46:47 UTC] Array ( [fr] => [en] => http://en.hotellescygnes.com ) [13-Apr-2014 18:46:47 UTC] pattern: #^(|http://en.hotellescygnes.com)# [13-Apr-2014 18:46:47 UTC] home: http://www.hotellescygnes.com [13-Apr-2014 18:46:47 UTC] opt: http://www.hotellescygnes.com [13-Apr-2014 18:46:47 UTC] remove lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/hotel-services-amenities/ [13-Apr-2014 18:46:47 UTC] add lang: http://en.hotellescygnes.comhttp://en.hotellescygnes.com/hotel-services-amenities/ [13-Apr-2014 18:46:53 UTC] requested: http://www.hotellescygnes.com/restaurants/ [13-Apr-2014 18:46:53 UTC] url: http://www.hotellescygnes.com/restaurants/ [13-Apr-2014 18:46:53 UTC] Array ( [fr] => [en] => http://en.hotellescygnes.com ) [13-Apr-2014 18:46:53 UTC] pattern: #^(|http://en.hotellescygnes.com)# [13-Apr-2014 18:46:53 UTC] home: http://www.hotellescygnes.com [13-Apr-2014 18:46:53 UTC] opt: http://www.hotellescygnes.com [13-Apr-2014 18:46:53 UTC] remove lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/restaurants/ [13-Apr-2014 18:46:53 UTC] add lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/restaurants/ [13-Apr-2014 18:46:59 UTC] requested: http://en.hotellescygnes.com/rates-reservations/ [13-Apr-2014 18:46:59 UTC] url: http://en.hotellescygnes.com/rates-reservations/ [13-Apr-2014 18:46:59 UTC] Array ( [fr] => [en] => http://en.hotellescygnes.com ) [13-Apr-2014 18:46:59 UTC] pattern: #^(|http://en.hotellescygnes.com)# [13-Apr-2014 18:46:59 UTC] home: http://www.hotellescygnes.com [13-Apr-2014 18:46:59 UTC] opt: http://www.hotellescygnes.com [13-Apr-2014 18:46:59 UTC] remove lang: http://www.hotellescygnes.comhttp://www.hotellescygnes.com/rates-reservations/ [13-Apr-2014 18:46:59 UTC] add lang: http://en.hotellescygnes.comhttp://en.hotellescygnes.com/rates-reservations/
OK thanks. Now I understand. On my test site, I have no entry for the default language in the array $this->options[‘domains’], while you have an empty entry.
It means that a disabled input can be filled (or not) in $_POST the two different ways so I have to manage that.
Thanks a lot for all your tests. I will soon release a development version to fix this and will let you know when it will be available. Waiting for this, I guess you can stay with 1.4.3.
Great, I’ll downgrade to 1.4.3 while waiting for the new version. Thank you for your support and reactivity on this !
Hi,
I have something similar…
When I click on my logo to go to the homepage, it should be going to mysite.com/nl but is redirecting automatically to mysite.com/nl/nl which is giving me a 404 page.
Any idea?
Regards,
Chantal@chantal C: It is considered impolite to interrupt another poster’s ongoing thread unless you are posting a solution or suggestion. As per the Forum Welcome, please post your own topic.
@chantal C:
Your problem has already been reported and should be solved in the current development version
http://wordpress.org/support/topic/failing-to-redirect-properly-after-update@rémy
Could you test the development version (1.4.4.3)? It should fix your problem now (you will have to resave your Polylang settings after activating the new version to enable the changes to your database)Unfortunately, it’s still not working. I resave polylang & permalinks settings, but it’s the same problem.
🙁 Let’s try something else.
Could you edit the file polylang/admin/settings.php at line 241 and replace:if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) { foreach ($_POST['domains'] as $key => $domain) { if (!empty($domain)) // don't store empty values. see http://wordpress.org/support/topic/url-trouble-since-144 $this->options['domains'][$key] = esc_url_raw(trim($domain)); } }
by
if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) { foreach ($_POST['domains'] as $key => $domain) { $this->options['domains'][$key] = esc_url_raw(trim($domain)); } $this->options['domains'][$this->options['default_lang']] = get_option('home'); }
and then resave your Polylang settings again.
- The topic ‘URL trouble since 1.4.4’ is closed to new replies.