4

Q1. is it possible to further optimize / compact the following rules, thereby making the entire redirections faster and easier to maintain in future? There are about twenty of these domains!! you get the picture of my problem! Thanks very much for any and all clues +1

RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^website.com$
RewriteRule ^$ en/home [R=301]
RewriteCond %{HTTP_HOST} ^website.de$
RewriteRule ^$ de/home [R=301]
RewriteCond %{HTTP_HOST} ^website.fr$
RewriteRule ^$ fr/home [R=301]

etc etc etc
Q2. should I chain these rules like putting [C] at end or ??

Q3. is this the proper fashion of redirecting from search engine point of view?

Sam
  • 403
  • 3
  • 7
  • 23

1 Answers1

1

With regards to Q1, the only way I can think of making it a bit more compact is to make part of your on-disk path to the sites reflect the url - that way you can probably get away with a handful of rules just to take the domain suffix and apply it to the path.

For Q2, I'd say it looks fine, although I'd add ,L to the [R=301], so it reads [R=301,L] - that'll stop mod_rewrite from going any further once it's found a match.

Lastly, for Q3 I think you're spot on with 301 - Google recommend using 301 Redirects, as this document on their site says.

Hope that helps!

Andy Smith
  • 1,798
  • 13
  • 15
  • Thanks Andy! all my questions are answered, the Fourth Question i have put in a separate page, as its about COMBINING multiple domains that all go to the same page, unlike the nature of this question where they are all spread, http://serverfault.com/questions/214211/compact-redirects-in-apache-htaccess-how-an-elegant-coding-question – Sam Dec 19 '10 at 17:29