WordPress.org

Support

Support » How-To and Troubleshooting » WordPress coexist with existing site code in php

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

    http://example.com/index.html

    and I want to see the wordpress site if I visit

    http://example.com or http://example.com/index.php

    Is it possible?

    Thank you.

Viewing 10 replies - 1 through 10 (of 10 total)
  • keesiemeijer
    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;

    @fredlim

    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:

    http://www.example.com or http://www.example.com/index.html

    but visit the new WordPress site:

    http://www.example.com/index.php

    However if I set the pritoirty to

    index index.html index.htm index.php

    then the WordPress site never show even I explicit type

    http://www.example.com/index.php

    It will always go to the old site.

    🙁

    Try changing:

    index index.html index.htm index.php

    to

    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

    Cheers

    Glad to know ur issue is solved.

    Out of curiosity – did you give above solution a try – http://wordpress.org/support/topic/wordpress-coexist-with-existing-site-code-in-php?replies=6#post-3553653

    I test the method again as suggested:

    Changing

    index index.html index.htm index.php

    to

    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 example.com/index.php and example.com/index.html respectively.

    For example.com/ – argument order in above line prevailed.

    When I had index index.html index.htm index.php – example.com/ used index.html

    When I had index index.php index.html index.htm – example.com/ used index.php

    When I had index index.html index.htm index.php – example.com/ 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 example.com AND index is set to index.php

    then WordPress will create internal redirect for example.com/index.php to example.com/

    If you test with a simple demo, then example.com/index.php and example.com/ – 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.