• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

BobbyVoicu.com

I'm curious about stuff

  • Home
  • Entrepreneurship Articles
  • Startup Videos
  • About Me
  • Blog / Archive
You are here: Home / Learn to program / htaccess 301 redirects

htaccess 301 redirects

May 22, 2021 By Bobby Voicu Leave a Comment

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.

◀Interviewing
Yahoo! sold for less than $5B▶

Filed Under: Learn to program, Misc

Bobby Voicu

Bobby Voicu writes here from time to time.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

About

I write about things that raise my curiosity. And I’m quite curious about all kinds of things.

For a full “About Me”, go here.

Recent Posts

  • I’m Gonna Live on a Boat
  • Plex on Rasberry Pi 4
  • Foundation: The Official Podcast
  • What is iOS 15 bringing?
  • I want: SteamDeck
  • SD Card formatter for Raspberry Pi compromised SD cards
  • Brandolini’s law or the bullshit asymmetry principle
  • Chat etiquette: Hi every time you start?
  • 5th Ocean: The Southern Ocean
  • The Impact of Work from Home

Friends

  • Dr. Alexandra Mircea
  • FreeBusy Meeting Scheduler
  • Miruna Sfia
  • PS Play Romania
  • Rød Mallo Leiva
  • Sami the Westie
  • Vlad Balan

The CEO Library Collections

  • Best Leadership Books
  • Best Productivity Books
  • Women Entrepreneur Books

Copyright © 2023 · Privacy Policy · Disclaimer