Question

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?

Was it helpful?

Solution

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]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top