WordPress.org

Ready to get started?Download WordPress

Forums

WordPress coexist with existing site code in php (11 posts)

  1. fredlim
    Member
    Posted 1 year ago #

    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.

  2. keesiemeijer
    moderator
    Posted 1 year ago #

    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;
  3. rahul286
    Member
    Posted 1 year ago #

    @fredlim

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

    index index.php;

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

  4. fredlim
    Member
    Posted 1 year ago #

    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.

    :(

  5. rahul286
    Member
    Posted 1 year ago #

    Try changing:

    index index.html index.htm index.php

    to

    index index.html

  6. fredlim
    Member
    Posted 1 year ago #

    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

  7. rahul286
    Member
    Posted 1 year ago #

    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

  8. fredlim
    Member
    Posted 1 year ago #

    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.

  9. rahul286
    Member
    Posted 1 year ago #

    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

  10. fredlim
    Member
    Posted 1 year ago #

    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?

  11. rahul286
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.