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. Hiding sub directory from a url string

    Hiding sub directory from a url string

    Technical SEO Issues
    5 3 2.8k
    • 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.
    • omega
      omega last edited by

      I have been trying for a few hours now to hide a sub-directory from a url string on a joomla site using .htaccess

      every method i have found either has no effect or breaks the site.

      i am aiming to change all links with component in them:

      http://mysite.com/component/music/7335

      to

      http://mysite.com/music/7335

      I am using the latest Joomla 2.5 install but not sure how or if that affects anything.

      Any help would be greatly appreciated

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

        This is taken from: http://www.digitalbuz.com/2009/10/21/hide-joomla-subdirectory-in-url/

        If you have a website in a sub directory and want to point your main URL to it, here's a trick that worked for us.

        We had a Joomla site installed in a sub-directory called "home".  This was sitting next to another directory called "dev".  The idea was to have 2 copies of the same website sitting next to each other:  a "development" site for testing, and a "live" production site.

        Scanning the web, we found many people offered the following solution, which involves creating a file called ".htaccess" with the following code:

        RewriteBase /
        
        # Add trailing slash if path does not contain a period or end with a slash
        RewriteCond %{REQUEST_URI} !(\.|/$)
        RewriteRule (.*) http://www.yoursite.com/$1/ [R=301,L]
        
        #Change http://yoursite.com to http://www.yoursite.com (Optional)
        RewriteCond %{HTTP_HOST} ^yoursite.com$
        RewriteRule ^/?(.*)$ http://www.yoursite.com/$1 [R=301,L]
        #Rewrites http://www.yoursite.com/subdir to http://www.yoursite.com/
        RewriteCond %{REQUEST_URI} !^/subdir
        RewriteRule ^(.*)$ subdir/$1 [L]
        

        hopefully that gives you what you need

        omega 1 Reply Last reply Reply Quote -1
        • omega
          omega @tgr0ss last edited by

          thnks tgr0ss but i am not attempting to point my main url to a sub-directory.  i have already seen the above method and it is not a solution for my problem.  i have over 100 thousand links with the url string component/music/etc in it and would simply like to hide the word component.

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

            I think URL rewriting is the answer.

            You don't want the exact example tgr0ss gave, but you should be able to use it to produce URLs that point to, yet hide the /component/ directory.

            1 Reply Last reply Reply Quote -1
            • omega
              omega last edited by

              i'm afraid in my situation the fix tgr0ss offers just gives me a 500 error.

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              • What directory should a site go in (url structure)?
                Mario.Souza
                Mario.Souza
                0
                6
                151

              • Wanted to shift a blog from sub domain to sub directory but...
                Dubs
                Dubs
                0
                4
                175

              • Multilingual Website - Sub-domain VS Sub-directory
                katemorris
                katemorris
                0
                8
                6.4k

              • Query strings in Canoncials URLs
                irvingw
                irvingw
                0
                4
                373

              • Crawl reveals hundreds of urls with multiple urls in the url string
                irvingw
                irvingw
                0
                5
                455

              • Tutorial For Moving Blogger Blog From Sub-Domain to Sub-Directory
                0
                1
                1.2k

              • Extra Sub Directory
                edwardlewis
                edwardlewis
                0
                4
                350

              • Sub domain versus sub directory
                sprynewmedia
                sprynewmedia
                0
                3
                663

              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