1

I have inherited an English/French static web site. The original developer created it so all the html files are in the root directory of the English domain and added "-fr" to the French file names, instead of setting up the English under the English domain and the French under the French domain (which we own).

This is not correct according to to the standards we need to work by. It should be French domain with French files, so that both domains and file names are in the same respective languages. I have to fix this and I'm really hoping to avoid having to restructure the whole site. I'm wondering if someone who is more versed in creative DNS configuration and redirects/rewrites than I am might be able to suggest a way to do this.

Example:

Current structure

  • englishdomain/englishfile.html
  • englishdomain/englishfile-fr.html

Correct structure

  • englishdomain/englishfile.html
  • frenchdomain/frenchfile.html

I haven't been able to find anything addressing this exact issue so far.

Thanks!

0

2 Answers 2

1

You just need to address the DNS thing first.

Add A or AAAA record same in both domain names as it is the same server or even you can choose to work with one principal domain to just have the need to update only one domain name A record.

Example:

Domain1.tld(@)      A     127.0.0.1
Domain2.tld(@)     CNAME  Domain1.tld

Then just organize the files iside the server in order to do french file or English file.

You have 2 options:

  1. Create a folder for each domain name and have it separately as you said they will be different domains and different languages you should have different folder sites (just my opinion).
  2. Create an HTTP handler of the URL when handling the connection of one domain or another to serve the correct files of the site language.
0

You could use a rewrite rule to add the -fr. This would go in the .htaccess file for your site under an Apache webserver.

RewriteCond "%{HTTP_HOST}" "^www\.frenchdomain\.example" [NC]
RewriteRule "^/?(.*)\.html" "/$1-fr.html" [L]

Then http://www.frenchdomain.example/filename.html would be powered by filename-fr.html.

I'm not sure if that rule would work for the home page or not. You might need a separate rule to serve the french home page out of index-fr.html.

This solution doesn't help if your frenchfile.html has a localized (in French) filename. I don't see a way to add a rule to cover that. If you want that, you'll have to fully restructure your site. I'd recommend breaking it into separate directories for the two languages at that point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.