Hey, I need my site in 2 x languages. So I followed this simple tutorial at bitrepository (Sorry would not allow me to post URL) to add language files using PHP. Right now I have 2 x php language files that can dynamically switch between the 2 languages which I like. * domain/index.php?lang=en * domain/index.php?lang=de All editorial text including page title etc in the index.php file is replaced with a link to those language files. * <?php echo $lang['MENU_HOME']; ?> So my concern is that this approach is bad for SEO purposes as the sites will just look like duplicates even though the content is different but the layout the same? I would really like some good advice if this approach is SEO compliant or I should rethink this approach, and if so to what? Thanks
The approach is correct, however its not currently SEO friendly (and the reason - you've already outlined within your initial post), theifore you can make use of mod_rewrite. Create a file named .htaccess (if it does'nt exist already) in your root directory and paste the following contents: <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^([a-z]{2})(?:/)?$ index.php?lang=$1 [NC] </IfModule> Code (markup): You'll require the mod_rewrite module loaded, and an Apache webserver - most hosting evironments (especially shared) are equipted with all these requirements, so should'nt be an issue. (Note: If your using localhost with XAMPP then this is'nt a problem - ignore this). Then you simply refer to it (within HTML links) and access it as the following: If your using online hosting: http://domain.tld/en/ for english http://domain.tld/de/ for german etc. (http://domain.tld is the address of your website e.g. http://digitalpoint.com). OR http://domain.tld/project/en/ for english http://domain.tld/project/de/ for german etc. If your using localhost (XAMPP etc.): http://localhost/en/ for english http://localhost/de/ for german etc. OR http://localhost/project/en/ for english http://localhost/project/de/ for german etc. So in simple form, just prepend the two letter country/language code to the end of your domain, to access index.php under that language, its also case insensitive. Your site/project should now have SEO friendly language URLs!
@danx10 - First off, thanks for the reply to help me out. I prob should of said in my original post but I am a bit of a noob when it comes to PHP so you will have to forgive my ignorance in the next few questions. Note: I am running everything locally at the moment as the site is being built by me. I am on a Mac OSX 1.6 and using XAMPP to run Apache and MY SQL.. * First questions is, does what you recommend solve the SEO issue? Meaning there was an issue with what I have implemented? * So I have created a .htaccess file and added it to the root with the code as you have above * "You'll require the mod_rewrite extension loaded, and an Apache webserver" - Right I defo have Apache running as I can see that in XAMPP module, but I am not sure what the mod_rewrite extension is or if that is loaded? Could you clear that up? * "Then you simply refer to it (within HTML links) and access it as the following:" - Got it. But I guess I am missing something for this to work. Also I have another note on this later.. * In the URL you posted you have tld. Sorry if this sounds stupid which I am sure it does, but I guess you just mean com or whatever it ends with? So for example when working from localhost for me would the URL look like this? localhost/project/en ? The only other note I had, is that I actually purchased the domains for both the .com and the .de so maybe this helps in having the sites load different content and have separate HTML files and not use PHP for this? Only issue I would not know how to solve is that I only have 1 webhost for all the domains. But I am sure there is a work around. Again, sorry if this is lame... Thanks
redwall, XAMPP is fine, I've edited my initial post (with info for running on localhost). To avoid confusion, please confirm that the SEO language URLs are sorted (their accessible), so we can move on to any other related questions you may have.
Hey Thanks but unfortunately I just can't get it to work. I have verified that I have mod_rewrite working with info.php and have tried hitting the URL's you mentioned for local host but I just keep getting "Object not found" 404 page... Also some info on my file structure if it helps...I have XAMPP control as I mentioned before. I have my project folder in the htdocs folder and the site runs fine when I go to my localhost/project ...so that all seems correct to me. The .htaccess file is located in the project folder along with everything else. Any further help is appreciated..Maybe it is a local host issue! ? Cheers
Ok try removing the RewriteBase line, in the .htaccess file. So it should look like: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^([a-z]{2})(?:/)?$ index.php?lang=$1 [NC] </IfModule> Code (markup):
Thanks for suggestion but still the same issue with the 404 object not found...Could it be that when I go to my default url localhost/project the site loads fine and that is the default URL (In English) It does not go to project/index.php?lang=en on initial load. This only happens when I switch between the language flags in the UI? Thanks for the help