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. SEO and Digital Marketing Q&A Forum
    2. Categories
    3. Technical SEO Issues
    4. Htaccess noob

    Htaccess noob

    Technical SEO Issues
    4 2 96
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as question
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • rich.owings
      rich.owings last edited by

      Hi all,

      I discovered that a site I'm working on has some pages from their old site that are stil live and getting traffic. I would like to add redirects for them to the .htaccess file.

      Unfortunately, I have zero experience writing or editing .htaccess files. Here is the existing .htaccess file:

      BEGIN WPSuperCache

      END WPSuperCache

      BEGIN WordPress

      <ifmodule mod_rewrite.c="">RewriteEngine On
      RewriteBase /
      RewriteRule ^index.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]</ifmodule>

      END WordPress

      And here are a few sample lines that I need to add:

      Redirect 301 /files/John-Doe.html /staff/
      Redirect 301 /files/Jane-Smith.html /staff/
      Redirect 301 /files/contact.html /contact/

      So my question is, should I place those lines immediately after Rewrite engine on, or just before the closing IfModule tag or...?

      There is no consistent pattern that would allow for a single rule or two. Oh, and I will backup the current .htaccess file first!

      Many thanks for any help anyone can offer.

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

        Hi there,

        Usually my advice is to add any custom code after the default WordPress rules, just to keep it more organised. It is very important not to add the rules in the WP section (# BEGIN WordPress ->  # END WordPress).

        Also I usually add comments before every rule group I create (just to have it more organised, and if anything goes wrong - check Search Console for anomalies after implementation - I know where I need to revert/adjust). You can add comments by starting the line with a # sign.

        I hope it helps.

        Oh and BTW, when using Redirect 301, you should use relative path for the OLD url and absolute path for the NEW url, so the lines that you provided need to contain the full URL for the new version:
        Redirect 301 old-relative-path.html http://www.yourdomaingoeshere.com/newurl/

        rich.owings 1 Reply Last reply Reply Quote 1
        • rich.owings
          rich.owings @Keszi last edited by

          Thank you so much for taking the time to reply. I appreciate you sharing your insights.

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

            I'm glad I could help! Let me know if you hit any walls with the implementation. 🙂

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • .htaccess redirects
              ThompsonPaul
              ThompsonPaul
              0
              15
              285

            • 301 redirect .htaccess
              Christy-Correll
              Christy-Correll
              0
              5
              234

            • Htaccess Rewrites
              Klement69
              Klement69
              0
              4
              316

            • Htaccess file
              DMGoo
              DMGoo
              0
              5
              437

            • My .htaccess has changed, what do i do to avoid it again...?
              eunaneunan
              eunaneunan
              0
              3
              332

            • Htaccess rewrites
              AndrewAkesson
              AndrewAkesson
              0
              7
              705

            • .htaccess help please
              Dr-Pete
              Dr-Pete
              0
              3
              461

            • Htaccess issue
              sesertin
              sesertin
              0
              8
              487

            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 - 2026 SEOMoz, Inc., a Ziff Davis company. All rights reserved. Moz is a registered trademark of SEOMoz, Inc.
            • Accessibility
            • Terms of Use
            • Privacy