• majorAlexa

        See all notifications

        Skip to content
        Moz logo Menu open Menu close
        • Products
          • Moz Pro
          • Moz Pro Home
          • Moz Local
          • Moz Local Home
          • STAT
          • Moz API
          • Moz API Home
          • Compare SEO Products
          • Moz Data
        • Free SEO Tools
          • Domain Analysis
          • Keyword Explorer
          • Link Explorer
          • Competitive Research
          • MozBar
          • More Free SEO Tools
        • Learn SEO
          • Beginner's Guide to SEO
          • SEO Learning Center
          • Moz Academy
          • MozCon
          • Webinars, Whitepapers, & Guides
        • Blog
        • Why Moz
          • Digital Marketers
          • Agency Solutions
          • Enterprise Solutions
          • Small Business Solutions
          • The Moz Story
          • New Releases
        • Log in
        • Log out
        • Products
          • Moz Pro

            Your all-in-one suite of SEO essentials.

          • Moz Local

            Raise your local SEO visibility with complete local SEO management.

          • STAT

            SERP tracking and analytics for enterprise SEO experts.

          • Moz API

            Power your SEO with our index of over 44 trillion links.

          • Compare SEO Products

            See which Moz SEO solution best meets your business needs.

          • Moz Data

            Power your SEO strategy & AI models with custom data solutions.

          Let your business shine with Listings AI
          Moz Local

          Let your business shine with Listings AI

          Learn more
        • Free SEO Tools
          • Domain Analysis

            Get top competitive SEO metrics like DA, top pages and more.

          • Keyword Explorer

            Find traffic-driving keywords with our 1.25 billion+ keyword index.

          • Link Explorer

            Explore over 40 trillion links for powerful backlink data.

          • Competitive Research

            Uncover valuable insights on your organic search competitors.

          • MozBar

            See top SEO metrics for free as you browse the web.

          • More Free SEO Tools

            Explore all the free SEO tools Moz has to offer.

          NEW Keyword Suggestions by Topic
          Moz Pro

          NEW Keyword Suggestions by Topic

          Learn more
        • Learn SEO
          • Beginner's Guide to SEO

            The #1 most popular introduction to SEO, trusted by millions.

          • SEO Learning Center

            Broaden your knowledge with SEO resources for all skill levels.

          • On-Demand Webinars

            Learn modern SEO best practices from industry experts.

          • How-To Guides

            Step-by-step guides to search success from the authority on SEO.

          • Moz Academy

            Upskill and get certified with on-demand courses & certifications.

          • MozCon

            Save on Early Bird tickets and join us in London or New York City

          Unlock flexible pricing & new endpoints
          Moz API

          Unlock flexible pricing & new endpoints

          Find your plan
        • Blog
        • Why Moz
          • Digital Marketers

            Simplify SEO tasks to save time and grow your traffic.

          • Small Business Solutions

            Uncover insights to make smarter marketing decisions in less time.

          • Agency Solutions

            Earn & keep valuable clients with unparalleled data & insights.

          • Enterprise Solutions

            Gain a competitive edge in the ever-changing world of search.

          • The Moz Story

            Moz was the first & remains the most trusted SEO company.

          • New Releases

            Get the scoop on the latest and greatest from Moz.

          Surface actionable competitive intel
          New Feature

          Surface actionable competitive intel

          Learn More
        • Log in
          • Moz Pro
          • Moz Local
          • Moz Local Dashboard
          • Moz API
          • Moz API Dashboard
          • Moz Academy
        • Avatar
          • Moz Home
          • Notifications
          • Account & Billing
          • Manage Users
          • Community Profile
          • My Q&A
          • My Videos
          • Log Out

        The Moz Q&A Forum

        • Forum
        • Questions
        • My Q&A
        • Users
        • Ask the Community

        Welcome to the Q&A Forum

        Browse the forum for helpful insights and fresh discussions about all things SEO.

        1. Home
        2. SEO Tactics
        3. Technical SEO
        4. 301 redirect syntax for htaccess

        Moz Q&A is closed.

        After more than 13 years, and tens of thousands of questions, Moz Q&A closed on 12th December 2024. Whilst we’re not completely removing the content - many posts will still be possible to view - we have locked both new posts and new replies. More details here.

        301 redirect syntax for htaccess

        Technical SEO
        3
        3
        8562
        Loading More Posts
        • Watching

          Notify me of new replies.
          Show question in unread.

        • Not Watching

          Do not notify me of new replies.
          Show question in unread if category is not ignored.

        • Ignoring

          Do not notify me of new replies.
          Do not show question in unread.

        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as question
        Locked
        This topic has been deleted. Only users with question management privileges can see it.
        • SamKlep
          SamKlep last edited by

          I'm working on some htaccess redirects for a few stray pages and have come across a few different varieties of 301s that are confusing me a bit....Most sources suggest:

          Redirect 301 /pageA.html http://www.site.com/pageB.html

          or using some combination of:

          RewriteRule + RewriteCond + RegEx

          I've also found examples of:

          RedirectPermanent /pageA.html http://www.site.com/pageB.html

          I'm confused because our current htaccess file has quite a few (working) redirects that look like this:

          Redirect permanent /pageA.html http://www.site.com/pageB.html

          This syntax seems to work, but I'm yet to find another Redirect permanent in the wild, only examples of Redirect 301 or RedirectPermanent

          Is there any difference between these? Would I benefit at all from replacing Redirect permanent with Redirect 301?

          1 Reply Last reply Reply Quote 1
          • IOHanna
            IOHanna last edited by

            There  is no difference between "Redirect 301", "Redirect permanent" and  "RedirectPermanent". It is clear from mod Alias documentation:

            "This directive makes the client know that the Redirect is permanent (status 301). Exactly equivalent to Redirect permanent."   "permanent - Returns a permanent redirect status (301) indicating that the resource has moved permanently."

            But, these directives are really confusing, because they are not page to page, but directory to directory.  For example:

            Redirect 301 /a-very-old-post/ http://yoursite.com/a-very-new-post/

            Surprisingly, it will redirect all old subpages to new subpages. In particular it will redirect  /a-very-old-post/page1 to /a-very-new-post/page1  Therefore better to use RedirectMatch or RewriteCond+RewriteRule for page by page redirections and for redirections with query strings.

            Links to docs: https://docs.oracle.com/cd/B14099_19/web.1012/q20206/mod/mod_alias.html

            Link to simple RedirectMatch page by page redirects generator: RedirectMatch generator for htaccess https://www.301-redirect.online/htaccess-redirectmatch-generator

            Link to good RewriteRule generator: htaccess 301 redirect rewrite generator https://www.301-redirect.online/htaccess-rewrite-generator

            1 Reply Last reply Reply Quote 0
            • BlueprintMarketing
              BlueprintMarketing last edited by

              In **apache **"permanent" "RedirectPermanent" is  the same as "Redirect 301"

              By default, the "Redirect" directive establishes a 302, or temporary, redirect.

              If you would like to create a permanent redirect, you can do so in either of the following two ways:

              1. Redirect 301 /oldlocation http://www.domain2.com/newlocation
              2. Redirect permanent /oldlocation http://www.domain2.com/newlocation
              • See
              • https://www.digitalocean.com/community/tutorials/how-to-create-temporary-and-permanent-redirects-with-apache-and-nginx

              Page to Page 301 Redirect Generator for Htaccess

              https://www.aleydasolis.com/htaccess-redirects-generator/

              If no <var>status</var> argument is given, the redirect will be "temporary" (HTTP status 302). This indicates to the client that the resource has moved temporarily. The <var>status</var> argument can be used to return other HTTP status codes:

              <dl> "permanent" & "Redirect 301"</dl>

              <dl>

              <dd>Returns a permanent redirect status (301) indicating that the resource has moved permanently.</dd>

              "temp"</dl>

              <dl>

              <dt>Returns a temporary redirect status (302). This is the default.</dt>

              "seeother"</dl>

              <dl>

              <dd>Returns a "See Other" status (303) indicating that the resource has been replaced.</dd>

              "gone"</dl>

              <dl>

              <dd>Returns a "Gone" status (410) indicating that the resource has been permanently removed. When this status is used the <var>URL</var> argument should be omitted.</dd>

              </dl>

              **https://httpd.apache.org/docs/2.4/mod/mod_alias.html **

              https://www.askapache.com/htaccess/seo-search-engine-friendly-redirects-without-mod_rewrite/#seo-301-redirect-single-file

              https://www.bruceclay.com/blog/how-to-properly-implement-a-301-redirect/

              To 301 Redirect a Page:

              RedirectPermanent /old-file.html http://www.domain.com/new-file.html

              To 301 Redirect a Page:

              Redirect 301 /old-file.html http://www.domain.com/new-file.html

              https://i.imgur.com/PTEj5ZF.png

              https://www.aleydasolis.com/htaccess-redirects-generator/

              Single URL redirect

              Permanent redirect from pageA_.html_ to pageB.html.

              .htaccess:

              301 Redirect URLs.

              Redirect 301 /pageA.html http://www.site.com/pageB.html

              https://www.aleydasolis.com/htaccess-redirects-generator/page-to-page/

              <ifmodule mod_rewrite.c="">RewriteEngine On
              Redirect 301 /pageA.html /pageB.html</ifmodule>

              https://www.htaccessredirect.net/

              //Rewrite to www
              Options +FollowSymLinks
              RewriteEngine on
              RewriteCond %{HTTP_HOST} ^site.com[nc]
              RewriteRule ^(.*)$ http://www.site.com/$1 [r=301,nc]

              //301 Redirect Old File
              Redirect 301 /pageA.html /pageB.html

              You asked about Regex

              https://mediatemple.net/community/products/dv/204643270/using-htaccess-rewrite-rules

              .htaccess

              Regular expressions

              Rewrite rules often contain symbols that make a regular expression (regex). This is how the server knows exactly how you want your URL changed. However, regular expressions can be tricky to decipher at first glance. Here's some common elements you will see in your rewrite rules, along with some specific examples.

              • ^ begins the line to match.
              • $ ends the line to match.
                • So, ^folder1$ matches folder1 exactly.
              • . stands for "any non-whitespace character" (example: a, B, 3).
              • * means that the previous character can be matched zero or more times.
                • So, ^uploads.*$ matches uploads2009, uploads2010, etc.
                • ^.*$ means "match anything and everything." This is useful if you don't know what your users might type for the URL.
              • () designates which portion to preserve for use again in the $1 variable in the second string. This is useful for handling requests for particular files that should be the same in the old and new versions of the URL.

              See for more regex

              • http://perldoc.perl.org/perlre.html#Regular-Expressions
              • https://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet/
              • https://www.askapache.com/htaccess/

              Hope this helps

              Tom

              PTEj5ZF.png

              1 Reply Last reply Reply Quote 2
              • 1 / 1
              • First post
                Last post

              Browse Questions

              Explore more categories

              • Moz Tools

                Chat with the community about the Moz tools.

              • SEO Tactics

                Discuss the SEO process with fellow marketers

              • Community

                Discuss industry events, jobs, and news!

              • Digital Marketing

                Chat about tactics outside of SEO

              • Research & Trends

                Dive into research and trends in the search industry.

              • Support

                Connect on product support and feature requests.

              • See all categories

              Related Questions

              • AllChargedUp

                How do you fix redirect chains and temporary redirects?

                Hi, I have a lot of issues popping up with temporary redirects and redirect chains. I'm still confused as to what exactly redirect chains are and I don't know how to find where the "chains" are or how to fix them. I'm having two issues mainly:1. Temporary RedirectsI have around 100 pages on our www.twowayradiosfor.com website that are being flagged as temporary redirects. All of them have one thing in common: they are review pages (basically, when a customer clicks on the Review button to review a certain product, they are redirected to a review page for that product).URL Example:  https://www.twowayradiosfor.com/reviewhelpful.asp?ProductCode=CLS1410-COMBO&ID=44&yes=noI went into our website and set any URL containing the following as noindex:/review.aspWill that fix the issue? If yes, will I also need to do that for any URL containing /reviewhelpful.asp?2. Redirect ChainsIt seems like basically every product page on my website has this issue (over 100 pages). Here's an example of one:https://www.twowayradiosfor.com/Motorola-CLS1110-p/cls1110.htmI don't see any broken links on this page or links that redirect to another page that redirects, etc. What is causing this? Is it something on my header bar that is redirecting (since that header bar appears on every page, maybe that is why this issue shows up on a lot of pages)?I am new to Moz and still trying to figure this stuff out. I really appreciate any help. Thanks, Sawyer

                Technical SEO | | AllChargedUp
                0
              • MarketHubb

                Help Setting Up 301 Redirects from Coldfusion Site to Wordpress Site.

                I have created a new website and need to redirect all of the previous pages to the new one. The old website was built in coldfusion and the new site is built in wordpress. One of the pages I'm trying to redirect is www.norriseal.com/products.cfm to http://norrisealwellmark.com/products/. This is what I have in my .htaccess file <ifmodule mod_rewrite.c="">Options +FollowSymlinks
                RewriteEngine On
                RewriteBase /
                Redirect 301 /products.cfm http://norrisealwellmark.com/products/</ifmodule> The result of this redirect is http://norrisealwellmark.com/products.cfm How do I prevent the .cfm from appending to the destination URL?

                Technical SEO | | MarketHubb
                1
              • Kilgray

                Robots txt. in page with 301 redirect

                We currently have a a series of help pages that we would like to disallow from our robots txt. The thing is that these help pages are located in our old website, which now has a 301 redirect to current site. Which is the proper way to go around? 1- Add the pages we want to disallow to the robots.txt of the new website? 2- Break the redirect momentarily and add the pages to the robots.txt of the old one? Thanks

                Technical SEO | | Kilgray
                0
              • twotd

                301 redirect not working

                Hi there! I have recently moved a domain that has been indexed by google and setup redirects so that it forwards to the new domain. It seems like the only redirect that actually is working is the canonical and main domain but every other page and or page nested within a folder are not working. Here is an example of some of the redirects. Am I doing this wrong? It seems to be going to the new domain but can't find the actual pages.... RewriteEngine On
                RewriteBase /
                RewriteCond %{HTTP_HOST} !agoodsweep.com$ [NC]
                RewriteRule ^(.*)$ http://agoodsweep.com/$1 [L,R=301]
                redirect 301 woodstoveservicerepair.html http://agoodsweep.com/woodstoveservicerepair/
                redirect 301 /westchesterchimney.html http://agoodsweep.com/west-chester-chimney/ Thanks in advance for any help!!

                Technical SEO | | twotd
                0
              • JeanYates

                Delete 301 redirected pages from server after redirect is in place?

                Should I remove the redirected old pages from my site after the redirects are in place? Google is hating the redirects and we have tanked. I did over 50 redirects this week, consolidating content and making one great page our of 3-10 pages with very little content per page. But the old pages are still visible to google's bot. Also, I have not put a rel canonical to itself on the new pages. Is that necessary? Thanks! Jean

                Technical SEO | | JeanYates
                0
              • Adrian_Kingwell

                What tools produce a complete list of all URLs for 301 redirects?

                I am project managing the rebuild of a major corporate website and need to set up 301 redirects from the old pages to the new ones. The problem is that the old site sits on multiple CMS platforms so there is no way I can get a list of pages from the old CMS. Is there a good tool out there that will crawl through all the sites and produce a nice spreadsheet with all the URLs on it? Somebody mentioned Xenu but I have never used it. Any recommendations? Thanks -Adrian

                Technical SEO | | Adrian_Kingwell
                0
              • Kotkov

                302 or 301 redirect to https ?

                I am redirecting whole site to https. Is there a difference between 302 or 301 redirect for seo? Site never been indexed. Planning to do that with .htaccess command RewriteCond %{HTTPS} !=on
                RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] There are plenty of ways http://www.askapache.com/htaccess/ssl-example-usage-in-htaccess.html Which way would be the best? Thanks is advance

                Technical SEO | | Kotkov
                0
              • EvergladesDirect

                200 Redirects for SEO instead of 301

                We are working with a company on re-platforming our website.  On a call yesterday they outlined a strategy to use 200 redirects for our top keywords instead of 301s.  I am not familiar with this type of redirect and was wondering if anyone could provide some more insight.

                Technical SEO | | EvergladesDirect
                0

              Get started with Moz Pro!

              Unlock the power of advanced SEO tools and data-driven insights.

              Start my free trial
              Products
              • Moz Pro
              • Moz Local
              • Moz API
              • Moz Data
              • STAT
              • Product Updates
              Moz Solutions
              • SMB Solutions
              • Agency Solutions
              • Enterprise Solutions
              • Digital Marketers
              Free SEO Tools
              • Domain Authority Checker
              • Link Explorer
              • Keyword Explorer
              • Competitive Research
              • Brand Authority Checker
              • Local Citation Checker
              • MozBar Extension
              • MozCast
              Resources
              • Blog
              • SEO Learning Center
              • Help Hub
              • Beginner's Guide to SEO
              • How-to Guides
              • Moz Academy
              • API Docs
              About Moz
              • About
              • Team
              • Careers
              • Contact
              Why Moz
              • Case Studies
              • Testimonials
              Get Involved
              • Become an Affiliate
              • MozCon
              • Webinars
              • Practical Marketer Series
              • MozPod
              Connect with us

              Contact the Help team

              Join our newsletter
              Moz logo
              © 2021 - 2025 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
              • Accessibility
              • Terms of Use
              • Privacy

              Looks like your connection to Moz was lost, please wait while we try to reconnect.