Help with .htaccess rewrite for subdomain for multi language setup

On my host my ZP install lives in `public/www/`
I have set up subdomains like `public/fr/`, `public/nl/` etc.
My host does not allow me to point the subdomains to my ZP install so I put an .htaccess file in the `public/fr/` folder like this:

`

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^fr\.
RewriteCond %{REQUEST_URI} !^/fr
RewriteRule ^(.*)$ http://domain.com/fr_FR/$1 [P,L]

`
But I get a 404, Not Found.
Even when I do `RewriteRule ^(.*)$ http://domain.com/$1 [P,L]` I get a 400 "Your browser sent a request that this server could not understand. Size of a request header field exceeds server limit."

Maybe the mod_proxy is not enabled?
I need to use the P flag because the subdomains are outside the /www/ folder

Any help greatly appreciated!
.htaccess and rewrite rules drive me crazy everytime!

Comments

  • acrylian Administrator, Developer
    Just to be sure, `public/fr/, public/nl/` are of course no subdomains but subfolders. `http://fr.domain.com` and `http://nl.domain.com`would be sub domains (the `www` commonly used is a sub domain as well! That's why www.domain.com and domain.com are technically different addresses). And if you can setup sub domains you most certainly can define to link to any folder. Using subdomains only will work in the development nightly build of the coming 1.4.3 release, NOT with the trunk nightlies.

    Linking to `http://domain.com/fr_FR/` style links will not solve the problem with multilingual content as we widely discussed actually.
  • Yeah I mean I have set up subdomain http://fr.domain.com pointing to the folder `public/fr/`
    Unfortunately I can NOT define them to point to the ZP install. I can only them with files in the `public/fr/` folder, so I have put this .htaccess file to rewrite http://fr.domain.com to http://domain.com/fr_FR/
    Doing like this the user and search engines see http://fr.domain.com but the content from http://domain.com/fr_FR/ is served... unless I am not seeing that correctly?

    But I am wondering now, I tested sbillard's 9290 changeset on localhost with ZP version 1.4.2.1 [9138] just by adding the 2 lines in zp-core/functions-i18n.php and it seems to work fine?!
    Why are you saying linking to http://domain.com/fr_FR/ will not resolve the issue?
  • acrylian Administrator, Developer
    I don't know your host but mine lets me direct any domain to any folder on my public html folder or just the root, which would be `/` then. (you should not do that for SEO and duplicated content though that way).

    http://domain.com/fr_FR/ will not help as that url will not be static. It will be used to switch the url but that's all. The reason for the subdomain change, which will also switch languages, is to get separate addresse for each language content without JS and such. If that would do the trick all the talk and trying with the subdomains would not have been necessary at all (unless sbillard changed something else I lost track with).

    Btw you should NEVER just apply a few line change to an older release. The actual subdomain change involves a few more than that as changes in some plugins like sitemap, html_meta_tags etc.
  • Well my host does not allow me to set where to point the subdomain, just the contents of the subfolder, bummers.

    I understand http://domain.com/fr_FR/ is not static, but http://fr.domain.com is and that's what I rewrite for. It will only serve the content of http://domain.com/fr_FR/ and thus change the language, unless I really don't get it..

    OK I understand I should not just change files to an older release, I just want to prepare my subdomains on the production site when 1.4.3 get's released :-)
    My problem now is how to set up the subdomains to switch the language.
  • Let me see..

    a request is made for fr.domain.com
    fr.domain.com serves the content of domain.com/fr_FR/ with mod_rewrite
    content of domain.com/fr_FR/ switches the language to FR
    fr.domain.com uses the language FR

    we are on domain.com/news/
    the language switch url is fr.domain.com/news/
    fr.domain.com/news/ serves the content of domain.com/fr_FR/news/ with mod_rewrite
    content of domain.com/fr_FR/news/ switches the language to FR
    fr.domain.com/news/ uses the language FR

    we are on fr.domain.com/news/
    the language switch url is nl.domain.com/news/
    nl.domain.com/news/ serves the content of domain.com/nl_NL/news/ with mod_rewrite
    content of domain.com/nl_NL/news/ switches the language to NL
    nl.domain.com/news/ uses the language NL
  • acrylian Administrator, Developer
    Ok, I guess I indeed got your wrong as I could not imagine such restrictions from a host (I use only shared hosting and on all I know that is possible...). Sorry.

    Try something like
    `
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^m\.example\.com$
    RewriteRule ^ http://example.com/m%{REQUEST_URI} [L,P]
    `
    `m` would be the `fr` repectivly the `fr_FR` in the last line.
  • I think your confusion is with the folder name. If you are using subdomain locales (which is available in 1.4.2.2, btw) then you do NOT also use the folder.

    So if your site is installed in `localpath/zenphoto/` you would have a domain, `mydomain.com` which points to `localpath/zenphoto/` and subdomains for your languages, e.g. `fr.mydomain.com`, `es.mydomain.com` which point to `localpath/zenphoto` as well. You would select the your primary language in the general options. `mydomain.com` would render in that language. `fr.mydomain.com` would render in French, `es.mydomain.com` would render in Spanish.

    If your host indeed does not allow you to pick a specific folder for the subdomain then you will not be able to use this strategy. But if that is really the case you should ask them why.
  • Yeah it's crazy, they don't allow it.
    Even symlinks in the subfolders are not allowed.

    I asked them and they said it's not supported on their shared hosts, upgrade to dedicated blahblah.
    They said
    For what concerns your hosting pack, we could suggest you to use the .htaccess and mod_rewrite tools.
    You could place an .htaccess file in your subdirectories to rewrite the fr.domain.com URL to domain.com/fr/anything_else

    In this way the visitor or search engine will still see

    fr.domain.com/anything as address.
  • But of course, .htaccess will not work, since Zenphoto will see only the primary domain.

    Usually when a company thinks it knows better what I want to do than I do I will find a replacement company. Maybe you should look into a different provider.
  • If you wish to try it, the development build nightly will (after tonight) attempt to insert the locale into urls if you have the seo_locale plugin enabled. There may be some urls missed, so let us know of any issues.

    it will create links in the form /language/normal link
  • sbillard, WOW! I will check it out this week. Thanks so much :-))
    I really need multi language indexing. Multi language support is one of my first priorities and that's also why I found ZP!

    But
    But of course, .htaccess will not work, since Zenphoto will see only the primary domain.

    Could you explain that a little more? ZP wil only see the primary domain?
    Why is that? Why can't I seem to use .htaccess files in the subdomain folders?

    My structure is like this:
    subdomains:
    `
    /public/fr/
    /public/fr/.htaccess
    `
    ZP install:
    `
    /public/www/
    /public/www/.htaccess
    /public/www/index.php
    ...
    `
    Again, the P (proxy) flag in my RewriteRule in `/public/fr/.htaccess` should take care of the subdomain not being in the same vhost. But I suspect my host not to have mod_proxy enabled!! Waiting - again - for an answser to that question, and time flies by.
    You know this is a very respected European group. But I am getting tired of the "x feature is currently not supported on our shared hosting, please upgrade..."
    I am seriously thinking about switching to my old host...

    If the domain.com/language/contents approach will become supported in ZP that would rock!!
    I will donate the money that will save me switching hosts and transferring the domain, word!
  • Zenphoto sees the "rewitten" uri so a rewrite rule that changed the HOST from fr.public.com to public.com would leave Zenphoto without the fr prefix.

    The domain.com/language/contents will likely be supported. But it will need considerable debugging to be sure that nothing is missed (that is where you can help.) So long as all problems end up fixable the feature will be supported.

    But be aware that it does require Zenphoto to do a full redirect for each page requested. That is why the language.domain approach is prefered.
Sign In or Register to comment.