• I have a website. I need to add subdirectory to the Cpanel and need to use the same database to the subdirectories too.

    I need to redirect the users into subdirectories based on their geo.

    For example:

    example.com – my website
    example.com/uk – redirect users from uk.
    example.com/usa – redirect users from usa

    The contents will be the same on all the websites. So I need to use the same databases for all the subdirectories.

    • This topic was modified 6 years, 1 month ago by Jan Dembowski. Reason: Moved to Fixing WordPress, this is not an Developing with WordPress topic
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Are you trying to have 3 WP installations which all use the same DB? And use the same tables as well? Why not delete the physical subdirectories and extra installations and let the countries be an unimportant part of the WP permalink? As long as there are no pages or posts named “uk” or “usa”, that portion of the permalink will be ignored. As long as the actual page or post name is correct, it’ll be served regardless of extra terms in the permalink. These links would all go to a post named “hello-world” without any special effort:
    example.info/hello-world/
    example.info/usa/hello-world/
    example.info/uk/hello-world/
    example.info/meaningless/terms/hello-world/

    Thread Starter vijayj

    (@vijayj)

    Sorry I didn’t get the answer correctly.
    Can you explain a little about it.Or please share some document.

    In my case ,all the pages in the website should be included in the sub directies too.

    So all the sub directries will be the duplicate of the main website.

    Moderator bcworkz

    (@bcworkz)

    If each subdirectory will have the exact same content, you shouldn’t want to replicate WP a number of times. More work than necessary in maintenance. It can all be served from the same WP installation through different “virtual” URLs. WP ignores permalink terms it doesn’t understand, so you can insert arbitrary terms at will.

    The added benefit is you will not get penalized by search engines for having identical content at different URLs, provided the canonical link tag is the same in all cases.

    Thinking about such a scheme some more, it would be best to formalize the country terms as part of the rewrite rule set so requests not involving post and page names are handled correctly.

    If you would rather have multiple installations, that’s fine too. It’s your site 🙂 AFAIK they can all utilize the same DB tables. There might be an issue with edit locks working correctly if the same user is logged into more than one installation at a time.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Using the same database for subdirectory’ is closed to new replies.