Вопрос

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?

Это было полезно?

Решение

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]
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top