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. Remove a directory using htaccess

    Remove a directory using htaccess

    Technical SEO Issues
    4 3 2.2k
    • 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.
    • webtarget
      webtarget last edited by

      Hi,

      Can someone tell me if there's a way using htaccess to say that everything in a particular directory, let's call it "A", is gone (http 410 code)? i.e. all the links should be de-indexed?

      Right now, I'm using the robots file to deny access. I'm not sure if it's the right thing to do since Google webmaster tools is showing me the link as indexed still and a 403 error code.

      Thanks.

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

        Hi

        This should solve your problem

        <code>RewriteEngine on
        RewriteCond %{REQUEST_URI} ./folder/.
        RewriteRule (.*) http://www.yourdomain.com/gone.php [R=410,L]</code>

        Replace "folder" with the name of your folder and instead of a

        <code>http://www.yourdomain.com/gone.php</code>
        

        put link towards the page informing visitors that request resource is gone.

        Kind regards

        Bojan

        webtarget 1 Reply Last reply Reply Quote 0
        • webtarget
          webtarget @Yanbo last edited by

          That's great thanks.

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

            <colgroup><col width="205"> <col span="14" width="64"></colgroup>
            | Hello webtarget, First of all I want to tell you about the .htaccess file, It is the file which control the Apache webserver, is very useful and allows you to do a lot of things.  |
            | Here the below is the link which solves your whole problem regarding .htaccess file. Please check & review it. |   |   |   |   |   |   |
            | http://www.catswhocode.com/blog/10-awesome-htaccess-hacks-for-wordpress |   |   |   |   |   |   |   |   |   |

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            • Using 410 To Remove URLs Starting With Same Word
              vikasnwu
              vikasnwu
              0
              5
              408

            • What Metadata should one use multi country directory
              StephanSolomonidis
              StephanSolomonidis
              0
              2
              150

            • Remove Directory In Webmaster Tools
              BlueprintMarketing
              BlueprintMarketing
              0
              4
              117

            • Remove remove
              KeriMorgret
              KeriMorgret
              0
              4
              110

            • Removing URL Parentheses in HTACCESS
              JaredMumford
              JaredMumford
              0
              6
              1.5k

            • I am cleaning up a clients link profile and am coming across a lot of directories (no surprise) My question is if an obvious fre for all generic directory doesn't look to have been hit by any updates is it a wise move recommending tit for removal?
              TLM
              TLM
              0
              9
              353

            • How to remove entire directory off Google's Cache
              garygopinathan
              garygopinathan
              0
              2
              887

            • Directory Indexed in Google, that I dont want, How to remove?
              rfksolutionsltd
              rfksolutionsltd
              0
              3
              367

            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