Pergunta

I need redirect "year-slug" post/pages to same name subdomain, like this:

http://domain.com/2013/post-name/ to http://2013.domain.com/2013/post-name/

this is possible?

Foi útil?

Solução

Put this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?(domain\.com)$ [NC]
RewriteRule ^([0-9]{4})/.+$ http://$1.%1%{REQUEST_URI} [R=301,L,NE]
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top