# Joomla multilingual subdomain redirect/rewrite

**URL:** <https://www.ruby-forum.com/t/joomla-multilingual-subdomain-redirect-rewrite/220664>\
**Category:** NGINX\
**Created:** [June 15, 2012, 4:46pm UTC](https://www.ruby-forum.com/t/joomla-multilingual-subdomain-redirect-rewrite/220664 "2012-06-15T16:46:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 15, 2012, 4:46pm UTC](https://www.ruby-forum.com/t/joomla-multilingual-subdomain-redirect-rewrite/220664/1 "2012-06-15T16:46:49Z")

</div>

Hi all,

I have a multilingual Joomla website, whose URL currently look like the  
following :  
[http://www.example.com/fr/test/test.html](http://www.example.com/fr/test/test.html) (note the FR posision after the  
server name)

In order to achieve some SEO, I’d like my URLs to look like this :  
[http://fr.example.com/test/test.html](http://fr.example.com/test/test.html)  
Ie: the langage code is now part of the subdomain, and removed from the  
request\_uri

I configured my DNS ([fr.example.com](http://fr.example.com) and www.example) as A reccord  
pointing to the same IP address.

I tried the following rule, that match the fr langage code and display  
the correct URL, but I still have a 404 error because the server could  
not find the new rewritten page :

if ($request\_uri ~\* ^/(?fr)/(?.\*)$ {  
rewrite ^ http://$lang.example.com/$rest? permanent;  
}

Now, I’m looking for a way to tell the server to serve the page  
/fr/test/test.html when the URL is [http://fr.example.com/test/test.html](http://fr.example.com/test/test.html)  
Should I add a location @lang {} directive ? or use proxy pass ?

I’m quite new to Nginx, and I’m lost ☹

Moreover, I have several country codes such as: de, fr, cn, it… In  
this post i’m focusing on the fr one, but i’m looking for a generic  
solution.

Thanks !

Posted at Nginx Forum:

> **[Joomla multilingual subdomain redirect/rewrite](https://forum.nginx.org/read.php?2,227568,227568#msg-227568)**
>
> Hi all, I have a multilingual Joomla website, whose URL currently look like the following : http://www.example.com/fr/test/test.html (note the FR posision after the server name) In order to achieve some SEO, I'd like my URLs to look like this :...

---

<div class="post-metadata">

**Author:** ![clemclem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c77e96/32.png) [@clemclem](https://www.ruby-forum.com/u/clemclem)\
**Post date:** [June 17, 2012, 8:15pm UTC](https://www.ruby-forum.com/t/joomla-multilingual-subdomain-redirect-rewrite/220664/2 "2012-06-17T20:15:44Z")

</div>

Hi all,

In fact, I was looking for a transparent redirect. Here is what I finaly  
did :

server {  
server\_name ~^(?.+).example.com$;  
location / {  
rewrite /(.\*)$ /$lang/$1 break;  
proxy\_pass [http://www.example.com](http://www.example.com);  
proxy\_redirect [http://www.example.com](http://www.example.com)  
http://$lang.example.com/$request\_uri;  
}  
}

server {  
listen 80;  
server\_name [www.example.com](http://www.example.com);  
…  
}

One more question though : is there a way for Nginx to rewrite all the  
URLs in the generated page so they are all SEF ? ie:  
[http://fr.example.com](http://fr.example.com) instead of [http://www.example.com/fr](http://www.example.com/fr) ?

Posted at Nginx Forum:

> **[Re: Joomla multilingual subdomain redirect/rewrite](https://forum.nginx.org/read.php?2,227568,227628#msg-227628)**
>
> Hi all, I have a multilingual Joomla website, whose URL currently look like the following : http://www.example.com/fr/test/test.html (note the FR posision after the server name) In order to achieve some SEO, I'd like my URLs to look like this :...
