WordPress.org

Support

Support » Plugins and Hacks » Polylang » [Resolved] [Plugin: Polylang] Static home page 404 issue

[Resolved] [Plugin: Polylang] Static home page 404 issue

  • GREAT PROJECT ! (sorry for shouting, but it is 😉 )

    However, I ran into an issue:

    I have a static page as homepage and when setting the language option ‘Add language info to all URLS’s including…’ the site home page accessed via mysite.tld/ gets redirected to the static page URL without language info and then returns a 404 page. The home pages are only available via their respective URLs with language info in it.

    For example mysite.tld gets redirected to mysite.tld/home with a 404 while mysite.tld/en/home/ and mysite.tld/fr/accueil/ are listed in their respective language menus as home pages and can be accessed via those URLs just fine…

    Am I missing something here?

    http://wordpress.org/extend/plugins/polylang/

Viewing 15 replies - 1 through 15 (of 53 total)
  • Plugin Author Chouby

    @chouby

    I did introduce the ability to add the language code to all urls in 0.7. I didn’t want but so many users want it ! And although I recommend not to use it, so many users go straight checking the option 😉

    Well you discovered another bug… It does work if you hide the language code for the default language, but not if you uncheck this option.

    Will look into this…

    Hmmm… I see.

    The reason for checking the option is the fact that the site had been running another language plugin before so URLs with the language info in them had already been indexed by search engines. The site is relatively new and had little translations so there is no real problem unchecking that option again. URLs with the language info for the default language get redirected automatically to the correct url without the language info.

    Still, it would be nice if this could be resolved 🙂

    I’ve got other sites (using that other language plugin) that I might want to migrate to Polylang but they have been running much longer so the question of permalinks is much more relevant there. And I realize it might be a lot of extra work that has no direct visible impact but… It would be a REAL asset for those that would like to migrate from other language plugins if URLs would get redirected (with status 301?) depending on that setting, like for example:

    /en/news/ >> /news/ or /en/news/
    /fr/news/ >> /accueil/ or /fr/accueil/

    By the way, I might have run into a related issue with this static homepage (this time without this infamous option ‘Add language info to all URLs’ checked): My home pages get redirected correctly now but there are new ‘hidden’ pages. For instance, visitors coming to the main site URL mysite.tld/ with a Dutch browser get redirected to mysite.tld/welkom/ which is the static homepage but mysite.tld/nl/ will show another version: the front page listing posts instead of the static content… Same thing for all other languages on the site. Trying a URL for an undefined language like mysite.tld/de/ results in a 404 correctly.

    Complicated stuff.

    Marked thread as resolved since the upgrade to 7.2 did indeed fix it.

    With huge respect for great support 🙂

    Plugin Author Chouby

    @chouby

    A fix for the Error 404 has been included in 0.7.2. Just try it and tell me if it solves your issue.

    For instance, visitors coming to the main site URL mysite.tld/ with a Dutch browser get redirected to mysite.tld/welkom/ which is the static homepage but mysite.tld/nl/ will show another version: the front page listing posts instead of the static content…

    This is how Polylang currently works. In fact the language is a custom taxonomy. So when you browse mysite.tld/nl/, this is equivalent browsing mysite.tld/language/nl/ (you did choose to remove /language/) which is the custom taxonomy archive as defined by the WordPress core. So currently mysite.tld/nl/ and mysite.tld/page-for-posts-nl have the same content.

    You are not alone to request that mysite.tld/nl/ sends to the static front page instead of the list of posts. It’s on the roadmap… However don’t expect it for tomorrow. As you may have seen, the project has grown very quickly, so now I want to stabilize things a bit and take time to correct bugs before working on new features.

    Plugin Author Chouby

    @chouby

    You discovered the fix while I was writing the answer 🙂

    You are not alone to request that mysite.tld/nl/ sends to the static front page instead of the list of posts. It’s on the roadmap… However don’t expect it for tomorrow.

    Excellent, there is no hurry here. It’s not a real problem unless you’d consider duplicate pages (the static blog pages and these alternative dynamic home pages) a real problem… I’m not to worried since there is no direct link to these alternative home pages.

    Question: why did you choose to direct a static home page to a permalink including the page slug? By default, WP does not do this… mysite.tld/ will show the page with slug /home/ if that is set to static home page, while mysite.tld/home/ will redirect to mysite.tld/

    Would it not be more logical, since you seem to have aimed for this with dynamic home pages, to show each static home page translation on their respective mysite.tld/ (for default language, unless that infamous ‘Add language info to all URLs’ option is checked), mysite.tld/fr/ and mysite.tld/en/ counterparts without the slugs?

    Thereby replacing these alternative hidden home pages at the same time 😉

    Plugin Author Chouby

    @chouby

    Because it was easy like this 😀 I just had to write a redirection to make it work.

    Moreover, one of my most important goal is to avoid (as much as possible) site breaking when the plugin is deactivated. mysite.tld/fr/ will be broken if the plugin is deactivated which is rather annoying for a ‘homepage’. mysite/accueil/ will still exist if the plugin is deactivated 🙂

    OK, I see the point.

    Just to see what happens, I tried setting the slug for the french home page to /fr/ instead of /accueil/ … I get that alternative dynamic home page listing all latest french posts all the time now 😉

    Another little glitch I noticed when using the ‘Add language info to all URLs’ option: the /robots.txt generation gets broken 🙁

    That option also breaks my own plugin XML & Google News Sitemap Feeds but that was to be expected. I’ll have to find some way to make them compatible since Google News Sitemaps are language sensitive… as I did for qTranslate and xLanguage before. Hope I can bug you with questions about it some time 😉

    Plugin Author Chouby

    @chouby

    How do you generate the robots.txt ? I am rather old schooled and did that manually…

    You don’t generate a robots.txt, WordPress does that for you 🙂

    Remove (rename) your static robots.txt for a minute and check out the URL again. There should be a dynamically generated robtos.txt (with disallow rules depending on your WP privacy settings) … unless ‘Add language info to all URLs’ is checked.

    Plugin Author Chouby

    @chouby

    How could I imagine this ? Not even a generated file, but just a generated page ! Great… But now I have a bug to fix !

    Plugin Author Chouby

    @chouby

    This small modification should fix the robots.txt issue.
    Edit the file polylang.php at the line 342 (in 0.7.2) and replace:

    elseif ($is_archive || $is_comment_feed || $options['force_lang']) {

    by

    elseif ($is_archive || $is_comment_feed || ($options['force_lang'] && !strpos($rule, 'robots'))) {

    Excellent! 🙂

    By the way: can you tell me if there is a polylang variable during post loop which reflects the current posts language? Preferably in simple format for RSS use ( ‘en’ instead of ‘en_US’ ) …

    Plugin Author Chouby

    @chouby

    I use this:

    reset(explode('_', get_locale()));

    It’s standard WordPress and not linked to Polylang. Maybe I should provide a function which does this…

    OK, that might work… But only if get_locale() gets changed by Polylang depending on which post we are seeing in the loop. Is that the case?

Viewing 15 replies - 1 through 15 (of 53 total)
  • The topic ‘[Resolved] [Plugin: Polylang] Static home page 404 issue’ is closed to new replies.
Skip to toolbar