Wie kann man verschiedene /server mit derselben Domain haben?

Lesezeit: 4 Minuten

Benutzeravatar von Neo
Neo

Ich habe eine Webseite foo.com auf WordPress und ich möchte dies tun foo.com/mexico, foo.com/venezuelaLieferung anders /server für jede Stadt mit der gleichen Domain (ohne WordPress Multisite).

Ich frage nicht nach der Erkennung von IP nach Stadt, sondern nach Server- und / oder Domänen- / DNS-Konfiguration, um dies zu tun.

Ich weiß, dass es andere Möglichkeiten gibt, dies zu erreichen, aber ich möchte etwas über diese wissen.

Hier ist ein Beispiel:

http://www.vice.com/pt_br

http://www.vice.com/es_co


LÖSUNG BEARBEITEN

Das war meine Lösung:

  1. Erstellen Sie eine Subdomain, example.foo.com, die auf einen anderen Server verweist.
  2. Erstellen Sie auf dem Hauptserver einen Ordner mit dem Namen, den ich für den Link haben wollte, zum Beispiel „Mexiko“.
  3. In diesem Ordner erstellt eine .htaccess:

    RewriteEngine EIN
    Beispiel für RewriteCond %{REQUEST_URI} ^/mexico RewriteRule ^(.*)$ http://. foo. de/$1 [R=301,L,P

This works for me. If i want another /server i just repeat with another name, example ‘venezuela’. The subdomain name will be hide by the .htaccess and this ‘example.foo.com’ will look like this ‘foo.com/venezuela’.

  • If your wanting different sites, for each language, then follow my answer. If your just trying to support different translated languages, then use a translation plugin and make life a lot easier for yourself.

    – Wade

    May 30, 2015 at 7:25

ippi's user avatar
ippi

What you are describing is a reverse proxy.

You can set it up using apache’s extension mod_proxy. Personally I haven’t touched that, but my opinionated answer would be to suggest you have a look at nginx. It’s a dead simple reverse proxy. You can easily run nginx in front of apache, intercepting requests and passing them on to different servers or just send html-files directly.

A nginx-config can be as simple as:

server {
    listen       80;
    server_name  example.org  www.example.org;
    location /mexico/ {
        # We could have an apache server running on another port...
        proxy_pass http://127.0.0.1:8000;
    }
    location /venezuela/ {            
        proxy_pass http://123.123.123.123:8000;  # ...or another server.
    }
    location /bulgaria/ {
        # Or just serve some static files 
        # In apache, do you set up a virtual host for this? christ.
        root /var/www/static_html;

        # If static html is all you have, what is apache even doing 
        # on your server? Uninstall it already! (As I said; opionated!)
    }
}

edit: Finding my own answer after a few years, I’d just like to add that the 301-rewrite rule that OP choose to go with adds another request that the browser must wait for before getting redirected to the real address. 301-requests are still to this day considered bad SEO, and adds some (usually minor) loading time.

Wade's user avatar
Wade

You will need to use subdomains, and set the A records at your domain registrar to map each subdomain to the different servers.

Here is a related SO question. Note, it was closed, but the selected answer is what your going for: Subdomain on different host

one.yourdomain.com –> points to ServerA

two.yourdomain.com –> points to ServerB

There is info on GoDaddy’s site too. If your not using GoDaddy, the process would be similar: https://support.godaddy.com/help/article/4080/managing-a-domain-names-subdomains

You go into your domain registrar where you can edit your domain settings. It will probably be in something about DNS. Your wanting to add a new “A Record”.

Some registrars simply let you put in “yoursubdomain”, the IP of the server, and the TTL (Time To Live).

So enter your the subdomain for your first one, the IP of the server you want it to point to, and the TTL (if it asks) which is usually 3600.

Then add another “A Record”, only for your other subdomain, the IP for that server, and TTL.

Repeat for however many subdomains and servers you need.

  • I know it can be done with subdomains, but i want subdirectories, like the example: vice.com/pt_br vice.com/es_co So it will be a subdirectory pointing to a server and in that server is a worpress installation.

    – Neo

    Sep 25, 2015 at 4:00


  • Hi Neo, Have you achieved what you wanted to do? I have the same challenge as of yours. Kindly share the solution.

    – erTugRul

    May 22, 2018 at 11:17

  • @erTugRul Hey, I never noticed your question. Hope you get the solution from the question, I updated it as soon as I did it.

    – Neo

    May 2, 2019 at 10:55

your solutions is:

1.You can use A record & subdomains for every server.

2.You can use your webserver configuration to relay user to destination servers (Apache,NGINX & etc)

But here I see you’r asking about WordPress from multi server. You can only have multi server for your static contents (CDN), but your database must be in one place except you want to use cloud DB.

  • You can allow remote servers to connect to your database, without a cloud db solution. By default, only localhost can connect, but you can easily add (whitelist) other hosts.

    – Wade

    May 30, 2015 at 7:27

  • This is not secret, as I say he can use multi servers for static contents, It’s mean the db is single and on the main server. if he want to run single database on multi server he need cloud db. otherwise he can use method 1 or 2.

    – Milad Abooali

    May 30, 2015 at 14:19

1394260cookie-checkWie kann man verschiedene /server mit derselben Domain haben?

This website is using cookies to improve the user-friendliness. You agree by using the website further.

Privacy policy