WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] Home page shows posts in both languages / IIS (15 posts)

  1. wocai
    Member
    Posted 1 year ago #

    Hello, trying to get a site running on WP 3.5 / Polylang 0.9.8 at an IIS service provider. Site is currently at worldcameras dot info.

    Theme is the default Twenty Twelve, no other plugins active besides Polylang. Front page is set to display latest posts.

    Permalinks are set to Month and name, Polylang settings are attached to the top post on the site.

    The default language is set to et/Eesti/EST, but the homepage also shows post in en/English/ENG (I added the language to all post titles for testing).

    Tried a clean install in a subdirectory with default permalinks (so that no IIS rewrite rules were needed) and the problem was still there. Everything seemed fine on an Apache server, so I'm guessing this could be an IIS-specific issue. We would not like to switch hosts if possible, so any help is appreciated.

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

  2. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    That's very strange and although I never tested it, I have no idea why IIS should provoque this.

    Could you add these lines

    echo '<!--';
    print_r($query->query);
    print_r(is_home());
    echo '-->';

    in the file polylang/include/core.php at line 417, just above:

    // homepage is requested, let's set the language

    It won't solve your issue but may help me.

  3. wocai
    Member
    Posted 1 year ago #

    Thank you for the quick response. I added the following:

    echo '<!-- dbginfo:';
    print_r($query->query);
    echo 'is_home():';
    print_r(is_home());
    echo '-->';

    However, it seems that this code is not called on the default language home page at all, although it is called for all other posts and pages.

  4. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    OK. My first idea was not the right one. But the test helped.
    Could you put this debug info:

    echo '<!-- dbginfo:';
    print_r($query->query);
    echo 'suppress_filters: '; print_r($query->get('suppress_filters'));
    echo "\nis_home(): "; print_r(is_home());
    echo "\nscript_name: "; print_r($_SERVER['SCRIPT_NAME']);
    echo "\nindex: "; print_r($GLOBALS['wp_rewrite']->index);
    echo '-->';

    at line 392 just below the line:

    function pre_get_posts($query) {

    I now suspect either your index is not index.php or something wrong with the server variable 'SCRIPT_NAME'.

  5. wocai
    Member
    Posted 1 year ago #

    I added the new script and it seems that SCRIPT_NAME does show up as /Index.php with a capital "I". Not sure why that is or what to do about it.

  6. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    OK, so maybe we can solve your issue now by replacing 'index.php' by 'Index.php' at line 413. But that does not tell us why this 'I' is capitalized.

    Moreover I thought to replace this 'index.php' by $GLOBALS['wp_rewrite']->index but that would not help in your cas as this variable does not contain a capital 'I'.

    Is 'index.php' with a capital I in your web.config file? Is your filename 'index.php' with a capital I in your WordPress directory? Could you test with 'PHP_SELF' instead of the 'SCRIPT_NAME' in the debug info?

  7. wocai
    Member
    Posted 1 year ago #

    Using
    if (is_home() && false === strpos($_SERVER['SCRIPT_NAME'], 'Index.php')) {
    fixed the default home page, but broke things on the /en home page - widgets were showing content from both languages and the header linked to /, not /en, so it switched the language back to default.

    I added PHP_SELF and it also shows up as /Index.php

    As far as I can tell from two different FTP clients, both index.php in the root directory and the one in the wordpress directory have names starting with a lowercase 'i'. The rewrite rule also has a lowercase 'i':

    <rule name="wordpress" patternSyntax="Wildcard">
    	<match url="*"/>
    		<conditions>
    			<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/>
    			<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true"/>
    		</conditions>
    	<action type="Rewrite" url="index.php"/>
    </rule>
  8. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    Could you try with:

    if (is_home() && false === stripos($_SERVER['SCRIPT_NAME'], 'index.php')) {

    with 'stripos' instead of 'strpos' ?

  9. wocai
    Member
    Posted 1 year ago #

    Yes, that helped, almost everything is behaving consistently now, the only minor issue remaining from earlier is that the header in the English version links to the default language / instead of /en , but we can live with that, with the Home link in the Eng menu pointing to the English home page anyway.

    I think we'll have to talk to the hosting people about the root cause of this Index.php confusion, but with this fix the site is usable. Thank you for your time and happy holidays!

  10. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    In your theme, the link to the home by calling home_url( '/' ). Normally, Polylang filters this call and replace the home url by the home url in the correct language. In your case, for a reason I ignore, it does not work (works correctly on my test site with WP 3.5 and Twenty Twelve too).

    If you are interested, everything is done in the function home_url at line 825 of core.php. I wonder which test is broken in your case. Maybe it is still a matter of case sensitivity in the strpos at line 842... Could you try replacing 'strpos' by 'stripos'?

    Otherwise, you can create a child theme in which you replace all calls to home_url( '/' ) by pll_home_url()

  11. wocai
    Member
    Posted 1 year ago #

    stripos on line 842 did not help, but like I said, it is a very minor issue or no issue at all - I think it's OK that the header links to the default home page, not the language-specific one. So it is not worth overloading a bunch of stuff in a child theme.

    It all works as intended on our Apache test site, too, so it is very likely related to the original IIS / Index.php problem.

  12. lvsn
    Member
    Posted 1 year ago #

    Hi!

    I still have the same problem with my home page. Tried to follow your solutions, but that did not help.

  13. Chouby
    Member
    Plugin Author

    Posted 1 year ago #

    @lvsn, could you come back on your thread in which you exposed 2 problems. I proposed a solution for one of them but got no feedback since.

  14. mdj101
    Member
    Posted 1 year ago #

    I've got a similar problem whereby the homepage was giving a 404 error, but /index.php was OK.

    I'm using IIS7 and I got around this using a custom 404 that re-directs to index.php

    However, I have noticed that once logged in to admin the page shown is /wp-admin/Index.php although I cannot find any instances of a capital I anywhere.

    It seems that this capital I is causing the headache with the homepage not working.

  15. mdj101
    Member
    Posted 1 year ago #

    OK I've now resolved this issue.

    In IIS7 the default files ALL have capital I's at the beginning. Deleting Index.php and changing it for index.php has resolved the issue!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags