0

is it possible to keep certain parts of an URL and to rewrite the rest? With a .htaccess 301 redirect.

In my example I would like to rewrite URLs from this format

http://blog.example.com/post-name

to this one

http://example.com/2014/post-name

So far the year (2014) can be static because only a couple of links would be affected.

Thanks!

0
2

Keep in mind that this'll redirect every request to blog.example.com since it's just capturing anything after the slash and redirecting, so please clarify if you need it to be smarter, but..

RedirectMatch 301 ^/(.*)$ http://example.com/2014/$1
1
  • To clarify for anyone else: I pointed the .blog subdomain to an empty folder in which I put a .htaccess file with the above line. Works perfectly. Thanks. – Øle Bjarnstroem Nov 8 '14 at 21:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.