0
votes

I'm trying to automatically redirect a large number of subdomains to subfolders. Here's what I'm trying to do:

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

I'd like to replace dots in subdomains with dashed in subfolders. I currently have this regular expression/rewriterule:


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

This rewriterule returns "www.easybookings.nl/artiest/-".

1

1 Answers

0
votes

You need to use %1 and %2 back references here:

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]