2012-01-06 96 views
3

我想用htaccess来做到以下几点,如果可能的话。htaccess mod_rewrite .tld到特定文件夹

该网页以这种方式工作,通过domain.de/de/start获得索引文件,通过domain.de/en/start获得英文版。

如果用户访问domain.com我想他在domain.de/en/而不是domain.de/de/结束了,所以我需要的所有请求改写为domain.com但不要求有domain.com/xx/somethingdomain.de/en/

谢谢。

回答

3

如果我理解你清楚你只是想重定向到http://domain.com/http://domain.de/en/要重定向http://domain.com/XX/YY

将这个代码在你的.htaccess :

Options +FollowSymLinks -MultiViews 
RewriteEngine on 

RewriteCond %{HTTP_HOST} ^domain\.com$ 
RewriteRule ^$ http://domain.de/en/ [L,R=301] 
1

尝试使用HTTP_HOSTrewritecond

RewriteCond %{HTTP_HOST}=domain.de 
RewriteCond %{REQUEST_URI}=/    % redirect only the root 
RewriteRule ^/$ /de/start [L]    % to /de/start 

RewriteCond %{HTTP_HOST}=domain.de 
RewriteCond !%{REQUEST_URI}=/    % no root 
RewriteCond !%{REQUEST_URI}=/[a-z]{2}/.* % except /xx/ directories 
RewriteRule ^/.*$ /de/$1 [L]    % push the user in the /de/ directory 
相关问题