bytesource Posted January 12, 2013 Share Posted January 12, 2013 Hi, The content of the website I am working on needs to be available in different languages.I thought about using different subdomains for each language, like es.example.com, de.example.com.With the help of static translations and multi-language fields it should be easy to switch the language content using this code snippet: if($config->httpHost == 'es.example.com') { $user->language = $languages->get("spanish"); } To test this approach on a live server I added a subdomain temp.example.com and had it point to the root folder of my current website. The problem is that when I type in temp.example com/some_page I get redirected to www.example.com/some_page.Of course, this redirection will not work well with search engines, so I would like to ask if there is a way to stop the redirection subdomains.Additional information: The website I added the subdomain to is not a ProcessWire installation but is running on an old version of ModX. The hosting provider is Hosteurope Cheers,Stefan Link to comment Share on other sites More sharing options...
Pete Posted January 12, 2013 Share Posted January 12, 2013 Well first off I'd say try it in ProcessWire so we can rule out MODx as the issue. Link to comment Share on other sites More sharing options...
MichaMichaMicha Posted January 12, 2013 Share Posted January 12, 2013 Looks like a .htaccess issue. Maybe there is a rule in your .htaccess that forces all subdomains to the www. version? Might want to add an exception for each subdomain? https://github.com/ryancramerdesign/ProcessWire/blob/master/htaccess.txt#L89 That is the line (and below) for the redirect of subdomains, my best guess you have a similair line like that in your MODx .htaccess 1 Link to comment Share on other sites More sharing options...
bytesource Posted January 13, 2013 Author Share Posted January 13, 2013 @ Pete You are right, using ProcessWire on the server would make thinks easier to debug. Unfortunately, my site is far from ready, so I don't want to replace it with the current site at this moment. The site I am working on is just my business site, and I don't have any other sites to play with. @ MichaMicha Maybe there is a rule in your .htaccess that forces all subdomains to the www. version? Might want to add an exception for each subdomain? That was exactly the problem. Before, the rewrite rule in my .htacces file looked as follows: RewriteCond %{HTTP_HOST} . RewriteCond %{HTTP_HOST} !^www\.sovonex\.de [NC] RewriteRule (.*) http://www.sovonex.de/$1 [R=301,L] After commenting out these three lines, typing subdomain.domain.com does not redirect to www.domain.com anymore. However, clicking on any internal link on the page still redirects to www.domain.com/some_page. I attached the current htaccess file, as I could not find anything that would explain this behaviour. Maybe someone using subdomains could post their relevant rewrite rules here. Cheers, Stefan modx_htaccess.txt Link to comment Share on other sites More sharing options...
ryan Posted January 14, 2013 Share Posted January 14, 2013 However, clicking on any internal link on the page still redirects to www.domain.com/some_page. I took a look at your htaccess, and it appears to me that all the stuff that would matter here has been commented out. So I don't think that's the problem. Can you tell if the links that you click on actually have the full hostname in them? View the source or inspect the link and see if it includes the hostname. Ideally you'd want the link to be like "/path/to/page/" and not "http://domain.com/path/to/page/". ProcessWire itself never uses hostnames in its URLs for this reason, unless you manually put them in or you use the $page->httpUrl rather than $page->url. If you find that's not the problem, I would try it from another browser. Browsers can be pretty stubborn about letting go of hostname related 301s. Link to comment Share on other sites More sharing options...
bytesource Posted January 14, 2013 Author Share Posted January 14, 2013 All internal links are relative links, but I just realized that I had a <base> tag in the header specifiying the default URL. After commenting this line out, typing subdomain.domain/some_page did not redirect to the main domain anymore. Thanks a lot for pointing me in the right direction! Cheers, Stefan 1 Link to comment Share on other sites More sharing options...
Recommended Posts