Forum Moderators: phranque
Here is my .htaccess file in nl.example.com:
ErrorDocument 400 /error400.html
ErrorDocument 401 /error401.html
ErrorDocument 403 /error403.html
ErrorDocument 404 /error404.html
ErrorDocument 500 /error500.html
RewriteEngine on
RewriteCond %{REQUEST_URI}!\.[^(xml¦txt¦ico¦gif¦png¦jpg)]$
RewriteRule ^hotel([^.]+).html$ http://www.example.com/hotel$1.html?Lang=nl [L]
Redirect ^/(.*) http://www.example.com/$1!\.[^(html¦xml¦txt¦ico¦gif¦png¦jpg)]$
[edited by: KoenG at 3:05 pm (utc) on Nov. 1, 2007]
[edited by: jdMorgan at 3:23 pm (utc) on Nov. 1, 2007]
[edit reason] example.com [/edit]
Your first rule should look like this:
RewriteCond %{REQUEST_URI} !\.(xml¦txt¦ico¦gif¦png¦jpg)$
RewriteRule ^hotel([^.]+)\.html$ http://www.example.com/hotel$1.html?Lang=nl [R=301,L]
Jim
[edited by: jdMorgan at 3:21 pm (utc) on Nov. 1, 2007]
The RewriteRule was to forward the specific hotel#*$!X.html pages to the main site with the language parameter added.
But this does not redirect all hits on the sub-domain. And that's where my problem lies: all other hits must be redirected except for the hits on .xml, .txt, ... pages. I tried the redirect with a regex expression but that doesn't work obviously.
When I access nl.example.com/sitemap.xml everything goes right.
When I access nl.example.com/hotel123.html everything goes as I expected.
When I access nl.example.com/ I get a 403 error message.
So all requests except for html¦xml¦txt¦ico¦gif¦png¦jpg must be redirect completely to the main domain.
# If not specific filetypes, redirect 'hotel' URLs to main domain
RewriteCond %{REQUEST_URI} !\.(xml¦txt¦ico¦gif¦png¦jpg)$
RewriteRule ^hotel([^.]+)\.html$ http://www.example.com/hotel$1.html?Lang=nl [R=301,L]
# Else redirect all others
RewriteCond %{REQUEST_URI} !\.(html¦xml¦txt¦ico¦gif¦png¦jpg)$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Jim
[edited by: jdMorgan at 9:46 pm (utc) on Nov. 1, 2007]
Thanks for the help.
All hits on / work fine now.
But a hit on nl.example.com/sitemap.xml is also forwarded to www.example.com/sitemap.xml
It is my specific intention to have separate sitemaps for every language (== subdomain) as the search engines will visit the hotel pages on the subdomain and will be forwarded to the main domain with the correct language parameter, thus resulting in indexed pages for every language and better SERPs per language.
Everything is hosted at the same provider and the sub domains are subdirectories of the main domain (handled with CPanel).
Maybe it's better with the real world example (with your last suggestions effective):
http://nl.example.com/ goes to the main page of main domain, correct now.
http://nl.example.com/sitemap.xml shows the sitemap of the main domain and not the subdomain (not what I intended)
http://nl.example.com/hotel46265.html goes to the Dutch translation of the request page on the main domain, correct.
[edited by: jdMorgan at 10:34 pm (utc) on Nov. 1, 2007]
[edit reason] example.com [/edit]
This system works fine, except that GoogleBot has no browser language, thus only 'sees' the English pages when crawling my site.
It is my experience that SERPS for local languages are better when requested from a localized Google site (e.g. google.nl in Dutch).
And that's why I created this 'complicated' system... I serve Google sitemaps on a (localized) sub domain. When GoogleBot visits pages on the sub domain they redirect to the main application domain including the language parameter resulting in localized pages in the indexes.
This system is running for some weeks now with success. So far I have not yet been penalized for duplicate content and the SERPS are better indeed for other languages than English.