• I just did an install of the current version of WordPress (5.8.1) for a new site. I set it up the same way I’ve done numerous times with this Web host — perhaps with the exception of using Ubuntu Linux rather than Mac or Windows this time.

    After I uploaded the files, accessed the website, and entered my credentials, I visited the main page of the site. I soon learned that all the permalinks had “index.php” in them (e.g., https://www.example.com/index.php/2021/10/09/hello-world/). Since this would be a step backward for WordPress, I was wondering if anyone knew why this was happening and how I can fix it. Will a fresh install be best?

    My Web host said it’s possible WordPress now writes URLs this way, given they’ve had a number of recent major updates. So maybe my inclination is wrong and this is how WordPress works now.

    I ask if it’s best to do a clean install in the event this behavior indicates there may be more problems with the install.

Viewing 8 replies - 1 through 8 (of 8 total)
  • This boils down to a server config issue.

    In most cases, you can remove this index.php from SETTINGS => PERMALINKS and you shouldn’t have any issues after that.

    My Web host said it’s possible WordPress now writes URLs this way, given they’ve had a number of recent major updates.

    You may want to add this to your TO DO list: “Find a new host that has a clue what they’re doing” ??

    Thread Starter pugs

    (@pugs)

    Thanks so much, @gappiah! You fixed it!

    This is what I saw when I went to the Settings -> Permalinks page: the “Custom Structure” radio button was selected with the URL of my new site (https://www.example.com). Then in the text box next to that URL it contained: /index.php/%year%/%monthnum%/%day%/%postname%/

    So I just selected the “Day and name” radio button instead, as it is on my other WordPress sites, and like magic all my URLs were fixed.

    Now I’d like to know if anything else could be damaged with this install. Should I do a clean install or just use it as it is? Does anyone know how this happened and what all could be affected?

    Oh, and regarding my host, they are Pair Networks, one of the oldest and best web hosts out there. I think this issue was just above the scope of knowledge of the support person who answered the phone. Their support is usually great.

    There’s nothing wrong with your install – this is actually the WP default permalink structure.

    Thread Starter pugs

    (@pugs)

    Hi, @maxxd. Thank you.

    What makes you say that it’s actually the default WordPress permalink structure? I’ve installed WordPress numerous times over the years, and this is never how it was in the past. Furthermore, I’ve seen very few WordPress sites set up this way. Did the default just recently change in one of the minor releases? Could you provide any links to documentation or anything?

    Hi @pugs

    As far as I recall, every install I’ve done starts off with this permalink structure and needs to be changed.

    As maxxd said, there’s nothing wrong with your WordPress installation.

    And as I said earlier, this boils down to a server config issue.

    If you look at the default WordPress permalinks rewrite rules for Apache below, you’ll see there’s this index.php in there. Whether you have this index.php appears in your URLs or not depends on how the rewrite rules are processed on the server.

    If the rules are processed by Apache’s mod_rewrite module, you won’t the index.php will not appear in your permalinks.

    If PATHINFO is used, you’ll see the index.php in the generated URLs (so-called “almost pretty” permalinks).

    If you want to dig deeper into this…

    A quick glance through the options-permalink.php file will tell you when WordPress decides to add or not add index.php to permalinks. Here’s the pertinent bit:

    if ( ! got_url_rewrite() ) {
      $prefix = '/index.php';
    }

    The got_url_rewrite() function checks whether the server supports URL rewriting or not. If this returns false, then PHP’s PATHINFO is used instead (and as the above code snippet shows, the prefix /index.php is then added).

    In many cases, the server may support URL rewriting… but WordPress may not be able to detect this correctly, and consequently adds the index.php prefix. That’s why your URLs don’t break when you remove the index.php prefix. (If the server didn’t support URL rewriting, then, of course, you’d have 404 errors after removing the index.php prefix.)

    Thread Starter pugs

    (@pugs)

    Thanks again for the responses.

    I did go ahead and do a clean install with a Windows machine in the event there were other errors in the initial install. I made another change, which I suspect could have caused the error. It has to do with the order of my edits in wp-config.php. In the www.remarpro.com article “Editing wp-config.php,” it says:

    Note: The contents of the wp-config-sample.php file are in a very specific order. The order matters. If you already have a wp-config.php file, rearranging the contents of the file may create errors on your blog.

    The problem is, toward the bottom of wp-config.php, there’s a comment that says to place your edits in the designated area. This comment in wp-config.php appears new, as I don’t remember it from my previous installs and didn’t find it in the files when I looked at them. Some of the edits I made, namely WP_SITEURL and WP_HOME, appear higher in order on the “Editing wp-config.php” article. So this time, rather than putting all my edits in the designated area, I put the aforementioned edits higher up, in the order they would be in in the article.

    Do you think this could have been causing the error?

    Needless to say, the second install worked the way it should, with no “index.php” in the URLs. This was great for my peace of mind and may have even prevented future errors.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘New Install of WordPress Includes “index.php” in All URLs’ is closed to new replies.