locked
Index.php appears in Wordpress permalink URL, but Rewrite Rule in web.config does not solve problem. RRS feed

  • Question

  • User-871665172 posted

    Installed on Windows 10 is, IIS 10, IIS Express 10, Visual Studio Community 2017 and PHP Tools (without paid debugging activated).

    Wordpress has been dropped into an empty Visual Studio Community 2017 PHP project.  A MySQL database and user was created in PHPMyAdmin and the credentials used during the Wordpress install.

    Wordpress runs; however, index.php appears in the permalink structure.

    I’ve been using VS and Webmatrix for years and I have never seen this before on my machines. This doesn’t happen in Webmatrix.  Although, I’ve not built a Wordpress site in Visual Studio Community 2017 until now.

    Research indicates the Rewrite Rule needs adding to the web.config file – it’s already there and the URL Rewrite Module is installed.

    When making changes to the web.config file, I noticed the changes weren’t making any difference.  The web.config file is not being recognised by VS.

    The Wordpress permalinks, can be custom changed in wp-admin to remove index.php.  But this doesn’t get to the root of the problem which is index.php showing in the URLs.

    Questions:

    • How do I remove index.php from the Wordpress URLs?
    • Why is the web.config file is not being recognised by VS? How to I change this please?
    • If VS is using a config file saved somewhere in the solution, can I add the Rewrite Rule to it or get VS to use the root web.config file I added instead?
    • Does the fact Wordpress permalinks can be custom changed mean re-write is configured somewhere else and actually working, so the index.php issue is down to something else?
    • In properties, I can choose web servers - built in web server, IIS Express and Custom web server. I thought VS used IIS Express, so why is there a built-in web server option as well as IIS Express?

    Any enlightenment would be appreciated - thank you.

    Edit: I have just found this extract from a post by @Cathy Zou here.

    "<rewrites> section must have IIS's URL rewrite module support.  From your  URL, it seem that, you application running with built-in IIS Express in VS, Which does not support URL rewrite"

    Does this mean I'm wasting my time?  I'm never going to remove the index.php in the URLs when I'm using VS and the built in web server?

    Friday, April 19, 2019 1:24 PM

All replies

  • User-871665172 posted

    After spending more than one day researching this problem, I thought it was time to ask for help.  However, nobody offered support, so I carried on and found some answers.  I’ll share what I learned.

    It seems the built-in web server in VS Community 2017 does not support URL rewrite.

    Using the built-in web server, the permalinks are what is called almost pretty, which includes index.php in the URL; see: this page.

    Therefore, to remove index.php from the URLs to achieve pretty permalinks IIS Express or the custom web server needs choosing and configuring in properties.

    To answer my own questions:

    How do I remove index.php from the Wordpress URLs?

    Use IIS Express or the custom web server.

    Why is the web.config file is not being recognised by VS? How to I change this please?

    Configuration is saved in the CSProj file for the built-in web server (I think).

    If VS is using a config file saved somewhere in the solution, can I add the Rewrite Rule to it or get VS to use the root web.config file I added instead?

    VS is using a config file saved somewhere in the solution - the CSProj file (I think). But as far as I know the Rewrite Rule cannot be added if the built-in web server is in use.  VS can use the web.config if a server other than the built-in web server is in use.

    Does the fact Wordpress permalinks can be custom changed mean re-write is configured somewhere else and actually working, so the index.php issue is down to something else?

    No.  Wordpress is probably handling the custom permalinks.

    In properties, I can choose web servers - built in web server, IIS Express and Custom web server. I thought VS used IIS Express, so why is there a built-in web server option as well as IIS Express?

    ‘I think’ the built-in web server is a form of IIS Express, but not the actual IIS Express, that’s why IIS Express is an option in properties/servers.

    If any of this is incorrect, please put me right.

    Saturday, April 20, 2019 12:30 PM
  • User-1204637165 posted

    Dear Danib,

    Why dont you just install wordpress on a linux machine running thee Lamp stack.

    Honestly you following a difficult part. Trust me.

    A linux machine running Apache or any equavalent server to run php would just make life easy.

    There is this saying from experience programmers. Use the best tool to solve the problem.

    Best Regards.

    Sunday, April 21, 2019 1:01 PM