Support » Fixing WordPress » WordPress coexist with existing site code in php

  • Hi, I am using Nginx + PHP-FPM + MySQL stack.

    I am struggling in mixing an existing site and WordPress. Eventually the existing site will migrate to WordPress, so I want the existing site keep as is and WordPress install in the same directory, and I am intent to enable Multisite function.

    I search on the Internet to configure the site can run .html php code and WordPress under the same root directoy. However, if there is an index.html exists, the wordpress could not be load, Nginx always process index.html.

    I want to see the old site if I type

    and I want to see the wordpress site if I visit or

    Is it possible?

    Thank you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator keesiemeijer



    In Apache’s .htaccess you can set this in your .htaccess file:

    DirectoryIndex index.php index.html index.htm

    Here index.php comes up first, if not there then index.html, and after that index.htm.

    Not sure if this will work with Nginx. I ran it through a converter and this came up:

    index index.php index.html index.htm;


    Just add one-line in server {..} block:

    index index.php;

    After that reload nginx config. That should do the magic.

    Thanks all and appreciate for your help.

    I checked my Nginx config, it is same as your solution. I wrongly stated my problem.

    I would like to visit my old site if I type: or

    but visit the new WordPress site:

    However if I set the pritoirty to

    index index.html index.htm index.php

    then the WordPress site never show even I explicit type

    It will always go to the old site.


    Try changing:

    index index.html index.htm index.php


    index index.html

    Finally I use a workaround to achieve the result.

    I create a html template with a redirect link in <header>, in WordPress create an empty page and use that html template, then set the Setting->Reading->Front page to that empty page, which will redirect to my index.html


    Glad to know ur issue is solved.

    Out of curiosity – did you give above solution a try –

    I test the method again as suggested:


    index index.html index.htm index.php


    index index.hhtml

    does not work. But I was enabled the multisite after I deployed the redirect index.html method, so not sure the above method not working is cause by multisite or not.

    I don’t think multisite will create any problem.

    Actually, I ran a simple test and found that, order of parameters matter most in line:

    index index.html index.htm index.php

    when both index.html and index.php exists.

    I ran a test where I created a simple index.php and index.html files.

    As expected index.php and index.html were accessible when I gave exact URL like and respectively.

    For – argument order in above line prevailed.

    When I had index index.html index.htm index.php – used index.html

    When I had index index.php index.html index.htm – used index.php

    When I had index index.html index.htm index.php – used index.html

    Yes that’s what I got initially, but then I cannot get to the index.php WordPress site in that setting. Any idea?

    If you are using wordpress on AND index is set to index.php

    then WordPress will create internal redirect for to

    If you test with a simple demo, then and – both will work

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘WordPress coexist with existing site code in php’ is closed to new replies.