Mobile app version of vmapp.org
Login or Join
Twilah146

: Change the subdomain and keep the rest of the url I'm working on a multilingual website, and I want to generate the links in this way: The site is domain.tld and defaults to English, It has

@Twilah146

Posted in: #Domains #Php #Subdomain

I'm working on a multilingual website, and I want to generate the links in this way:

The site is domain.tld and defaults to English,

It has some subdomains like fr.domain.tld which will be in French, de.domain.tld which will be in German, it.domain.tld which will be in Italian...

when the current page is the index, the links to other languages will be like this:

domain.tld, fr.domain.tld, de.domain.tld, it.domain.tld....

But when we are in another page like domain.tld/my-page, how do we generate the URLs to match the current page but with another subdomain/language using PHP

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Twilah146

1 Comments

Sorted by latest first Latest Oldest Best

 

@Welton855

Do you mean you want to be able to go from a page on the main site like...
domainname.com/sub1/sub2/page.php
to

fr.domainname.com/sub1/sub2/page.php

When someone clicks for the French version for example?

If all you need to do is move the /sub1/sub2/page.php and any variables part, you could look at the "parse_url" function...
php.net/manual/en/function.parse-url.php
Alternately, you may be able to do some URL rewriting to accomplish some of this, but I'm no Apache expert.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme