• Skip to main content

BobbyVoicu.ro

  • Home
  • Arhiva (2005-2013)
  • Home
  • Arhiva (2005-2013)

htaccess 301 redirects

Learn to program, Misc · May 22, 2021

From the archive · ← all archived posts

I’ve moved a lot of the sites over years from one domain to another, but I never remembered the htaccess redirect rules to do it. I always needed to search for them, sometimes finding different solutions that were never perfect.

Anyway, here are some of them, in case I need them again. I took them from this site, which has a lot more situations sorted out through redirects.

How do you redirect an entire site or domain to a new one?

Redirect 301 / http://www.domain.com/

How do you use rewriting to redirect from an old domain to a new domain?

RewriteEngine on
RewriteBase /
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

How do you use rewriting to redirect from a non-www to a www subdomain?

RewriteEngine on
RewriteBase /
rewritecond %{http_host} ^domain.com [nc]
rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc]

From here: Common Htaccess 301 Redirect Rules.

Bobby

Despre

Scriu. Fara un subiect anume, fara o tema anume.

Aici e o arhiva a perioadei 2005-2013, cand scriam ceva mai des pe blog.

Scrise recent

  • Logo-ul Blanket
  • Elogiu pentru o tastatura: Thinkpad T480
  • Cartile din 2025
  • Bucuria de a fi iritat (si, probabil, iritant)
  • Cum sa iti dai seama la ce esti bun(a)

Proiecte

  • BobbyVoicu.com
  • MixRift

Copyright © 2026 · BobbyVoicu.ro