如果可能,我想用htaccess执行以下操作。
网页以这种方式工作,您通过domain.de/de/start
获取索引文件,通过domain.de/en/start
获取英文版本。
如果用户访问 domain.com ,我希望他以domain.de/en/
而不是domain.de/de/
结束,因此我需要重写所有对域的请求。 com 但不是domain.com/xx/something
到domain.de/en/
感谢。
答案 0 :(得分:3)
如果我清楚地了解您,您只想将http://domain.com/
重定向到http://domain.de/en/
,但 NOT 想要重定向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 :(得分:1)
尝试使用HTTP_HOST
和rewritecond
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