Nexym
  • Business
  • Finance
  • Technology
  • Health
  • Life
  • More
    • Auto
    • Food
    • Health
    • Home
    • Space
    • Travel

Subscribe to Updates

Get the latest creative news from FooBar about art, design and business.

What's Hot
Flywheel Logo

Flywheel review in 2023

June 8, 2023
Mutual funds are a popular way to invest in today's stock market. Learn what mutual funds are and how they work, as well as their benefits and drawbacks.

What are mutual funds and how to use them

October 1, 2023
Learn more about Daylight Saving Time (DST), why it exists, how we came up with this idea, and why some countries don't follow DST.

Daylight Saving Time: How did we start changing clock

September 30, 2023
Facebook X (Twitter) Instagram
Nexym
  • Business
    Learn more about Daylight Saving Time (DST), why it exists, how we came up with this idea, and why some countries don't follow DST.

    Daylight Saving Time: How did we start changing clock

    September 30, 2023
    protectteamabusivecustomers featureimage min

    How to protect your team from an abusive customer

    September 7, 2023
    Learn the skills you need to become a great content writer. From writing, editing, and researching to storytelling and creative thinking.

    Top skills you need to become a great content writer

    August 20, 2023
    featured business

    How to see the bigger picture in business

    August 9, 2023
    What is a corporation? What does it mean to be incorporated? How do you start one? Read the definition of corporation, learn the different types of corporations and how to incorporate them.

    What is a corporation? Definition, meaning, types and more

    August 8, 2023
  • Finance
    Mutual funds are a popular way to invest in today's stock market. Learn what mutual funds are and how they work, as well as their benefits and drawbacks.

    What are mutual funds and how to use them

    October 1, 2023
    Find out more about the tax implications of your retirement income based on your yearly taxable earnings.

    Do you pay taxes as a retiree if you earn extra money?

    September 9, 2023
    Learn areas to reduce or eliminate your tax obligation when you receive a settlement.

    How to decrease or eliminate your tax burden on lawsuit settlements

    September 8, 2023
    Learn about the IRS TREAS 310 deposit refund from Social Security and how it relates to your tax return.

    What is a Social Security IRS TREAS 310 deposit?

    September 8, 2023
    Find out what's holding up the tax return process and how you can get access to your money faster.

    Learn why your tax return money is delayed

    September 3, 2023
  • Technology
    Flywheel Logo

    Flywheel review in 2023

    June 8, 2023
    Find out how the Xbox Series S compares to more advanced alternatives! We'll tell you everything you need to know, including specs and features.

    How Xbox Series S compares to more advanced alternatives

    September 9, 2023
    How to embed Tik Tok

    How to embed TikTok videos into your WordPress website

    September 7, 2023
    reviewsitewp featureimage min

    How to build a review site in WordPress

    September 7, 2023
    Choosing color scheme for your website

    How to choose the perfect color scheme for your WordPress website

    September 7, 2023
  • Health
  • Life
    Find out which New Balance running shoes are best for your foot type, and how to match them with the other features you're looking for in a shoe.

    5 of the best New Balance running shoes for each foot type and need

    September 9, 2023
    If you're looking for a stylish and comfortable athletic swimsuit fitted for large breasts, check out our list of the top 10 athletic swimsuits.

    The 10 best athletic swimsuits for larger chests

    September 4, 2023
    Learn about the recent rate hikes by Verizon and AT&T, what this means for consumers and how to keep your cell phone bill in check.

    Inflation has finally caught up with cell phone bills – Verizon and AT&T new increased rates

    September 3, 2023
    Spring is almost here, and Walmart has got you covered with the latest trends! Check out these fabulous finds that won't break the bank!

    Surprise! Walmart has awesome spring fashion items

    August 28, 2023
    Find the perfect birthday messages and quotes for a special friend. Share them with your best friend on their birthday!

    28 creative birthday wishes for your best friend

    August 26, 2023
  • More
    • Auto
    • Food
    • Health
    • Home
    • Space
    • Travel
Facebook X (Twitter) Instagram
Trending
  • Flywheel review in 2023
  • What are mutual funds and how to use them
  • Daylight Saving Time: How did we start changing clock
  • Is life insurance with no medical exam viable for healthy people?
  • Why Ford’s electric F-150 Lightning is excellent for road trips
  • The best outdoor chairs you can find on Amazon
  • Check out these discounts for 7 all-inclusive Caribbean resorts
  • Here are the best shoes for travel and airports
Nexym
Home » Technology » Tutorials
Tutorials

How to redirect your website using 301 redirects

Matthew DrummondBy Matthew DrummondJuly 23, 20232 Mins Read
Facebook Twitter LinkedIn Reddit Telegram WhatsApp Pinterest Email
redirectusing301redirects
Share
Facebook Twitter LinkedIn

Non-secure redirects

non-www to www

Google Chrome recently started hiding the www portion of URLs, but if you want your website to work via https://www.yourdomain.com instead of https://yourdomain.com, you can set this up using a 301 redirect.

Learn how to use 301 redirects in your .htaccess file in our quick guide.

You will need to add following code to the beginning of your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ https://yourdomain/$1 [L,R=301,NC]

Make sure to replace yourdomain.com with your actual domain name.

Once you save the file, your website will be automatically redirected from https://yourdomain.com to https://www.yourdomain.com.

www to non-www

To redirect your website from https://www.yourdomain.com to https://yourdomain.com, put in the following code to the beginning of your .htaccess file:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ https://yourdomain.com/$1 [L,R=301,NC]

Make sure to replace yourdomain.com with your actual domain name.

Secure redirects

Redirect entire domain to HTTPS

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect entire domain from HTTP to HTTPS and non-www to www

RewriteEngine On 
RewriteCond %{HTTP_HOST} !^www\. [NC] 
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
RewriteCond %{HTTP:X-Forwarded-Proto} !https 
RewriteCond %{HTTPS} off 
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

For all of the code snippets, make sure to always place the code at the beginning of your .htaccess file in the public_html directory of your hosting control panel.

People also viewed:

forcehttpsonsite featureimageHow to force HTTPS on your website 301redirectsfix404notfound featureimageHow to use 301 redirects to fix 404 not found pages on WordPress setupdomaingooglesearchconsole featureimageHow to set up your domain on Google Search Console howtocreateanemailforwarder featureimageHow to create an email forwarder in cPanel fixinsecureelementswebsite featureimageHow to fix insecure elements on your website
.htaccess 301 redirect
Share. Facebook Twitter LinkedIn Reddit Telegram WhatsApp Pinterest Email
Previous ArticleHow to reset your WordPress admin password
Next Article How to fix broken links on your WordPress website
Matthew Drummond

Matthew is a Nexym Technology writer. Having worked as a systems administrator for over 15 years gives him unique insight into the inner works of technology. Ultimately his passion for writing brought him to share his technical expertise with the world.

Related Stories

forcehttpsonsite featureimage

How to force HTTPS on your website

July 15, 2023
setupdomaingooglesearchconsole featureimage

How to set up your domain on Google Search Console

February 25, 2023
howtocreateanemailforwarder featureimage

How to create an email forwarder in cPanel

February 17, 2023
301redirectsfix404notfound featureimage

How to use 301 redirects to fix 404 not found pages on WordPress

February 14, 2023

Comments are closed.

Connect
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
  • LinkedIn
  • Reddit
  • TikTok
Don't Miss
Flywheel Logo Reviews

Flywheel review in 2023

By Matthew Drummond

Flywheel is a fast-growing web host that offers high-performance WordPress hosting for agencies, designers, and developers.

Mutual funds are a popular way to invest in today's stock market. Learn what mutual funds are and how they work, as well as their benefits and drawbacks.

What are mutual funds and how to use them

October 1, 2023
Learn more about Daylight Saving Time (DST), why it exists, how we came up with this idea, and why some countries don't follow DST.

Daylight Saving Time: How did we start changing clock

September 30, 2023
Learn about the benefits of getting life insurance without a medical exam and determine if it's the right choice.

Is life insurance with no medical exam viable for healthy people?

September 29, 2023
  • Auto
    • Auto Reviews
    • Electric
    • Insurance
  • Business
    • Company
    • Government
  • Entertainment
    • Movies
    • Music
  • Finance
    • Credit Cards
    • Crypto
    • Market
    • Personal Finance
  • Food
    • Coffee
    • Drinks
    • Holidays
  • Health
  • Beauty
  • Fitness
  • Food
  • Medical
  • Home
  • Backyard
  • Bathroom
  • Bedroom
  • Cleaning
  • Furniture
  • Home Office
  • Kitchen
  • Life
  • Astrology
  • Family
  • Fashion
  • Outdoors
  • Personal
  • Pets
  • Apple
  • Audio
  • Domain Names
  • Gaming
  • Google
  • Power
  • Reviews
  • Samsung
  • Destinations
  • Gear
  • Services
  • Space
  • Tourism
  • Technology
  • Tutorials
  • Web Hosting
  • WiFi
  • WordPress
  • Travel
  • Shopping
  • Sports
  • Work
  • Stocks
  • Television
  • Web Hosting
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn Reddit TikTok
© 2023 Nexym Media

Type above and press Enter to search. Press Esc to cancel.