重写(.htaccess)将子域重定向到子文件夹

时间:2014-02-18 08:37:05

标签: regex .htaccess mod-rewrite redirect rewrite

我正在尝试自动将大量子域重定向到子文件夹。这就是我想要做的事情:

http://gerard.joling.easybookings.nl/ - > http://www.easybookings.nl/gerard-joling/

我想用子文件夹中的虚线替换子域中的点。我目前有这个正则表达式/ rewriterule:


    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^([a-z]+)\.([a-z]+)\.easybookings\.nl$
    RewriteRule ^(.*)$ http://www.easybookings.nl/artiesten/$1\-$2 [R=301,L]

此重写符号返回“www.easybookings.nl/artiest /-".

1 个答案:

答案 0 :(得分:0)

您需要在此处使用%1%2返回引用:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^([a-z]+)\.([a-z]+)\.(easybookings\.nl)$ [NC]
RewriteRule ^(.*)$ http://www.%3/%1-%2/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^([a-z]+)\.([a-z]+)\.([a-z]+)\.(easybookings\.nl)$ [NC]
RewriteRule ^(.*)$ http://www.%4/%1-%2-%3/$1 [R=301,L]