1

我所有的网址都有以下架构:

domain.de/LANGUAGE/CATEGORY/PAGE.html

此网址将通过以下方式处理:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)\.html$ /?lang=$1&subid=$2&id=$3 [L,QSA]

所以我想要的是以下重定向:

#Start page:
domain.de -> www.domain.de/de/abc/index.html
domain.de/LANG/ -> www.domain.de/LANG/abc/index.html
www.domain.de -> www.domain.de/de/abc/index.html
wwww.domain.de/LANG/ -> www.domain.de/LANG/abc/index.html

#In general:
all pages without www should be redirected to page with www 

#subdomain
subdomain.domain.de -> www.domain.de/de/abc/xy.html

我的开始:

RewriteEngine On
# domain.de -> www.domain.de/de/abc/index.html
RewriteCond %{HTTP_HOST} ^(domain\.(de))$
RewriteRule .+ http://www.%1/%2/abc/index.html$0 [L,R=301]

# www.domain.de/de -> www.domain.de/de/abc/index.html
RewriteCond %{HTTP_HOST} ^www\.domain\.(de)$
RewriteRule ^%1/?$/abc index.html [L,R=301]

# subdomain.domain.de to http://www.domain.de/de/abc/xy.html
RewriteCond %{HTTP_HOST} ^subdomain\.(domain\.(de))$
RewriteRule .+ http://www.%1/%2/abc/xy.html [L,R=301] 

但现在我不知道如何继续。你能帮帮我吗?

4

1 回答 1

0

您可以使用以下代码:

RewriteEngine On
RewriteBase /

# domain.de -> www.domain.de/de/abc/index.html
RewriteCond %{HTTP_HOST} ^domain\.de$ [NC]
RRewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# subdomain.domain.de to http://www.domain.de/de/abc/xy.html
RewriteCond %{HTTP_HOST} ^subdomain\.(domain\.de)$ [NC]
RewriteRule ^$ http://www.%1/de/abc/xy.html [L,R=301]

# www.domain.de/de -> www.domain.de/de/abc/index.html
RewriteCond %{HTTP_HOST} ^www\.domain\.de$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{ENV:REDIRECT_STATUS} !200
RewriteRule ^(de|nl|en)/?$ /$1/de/abc/index.html [L]
于 2013-03-25T11:03:21.440 回答