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. Local Website Optimization
    4. Changing the sites root folder

    Changing the sites root folder

    Local Website Optimization
    11 3 586
    • 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.
    • Ray-pp
      Ray-pp last edited by

      Hi Alex - Are you saying that you want your www.domain.com to resolve to www.domain.com/devs/ ?

      If so, I would highly suggest that you consider using www.domain.com as your primary location and URL - unless your website is somehow targeted to 'devs' and it make sense to keep it in the URL structure. If not, it is preferred to have the shorter, more concise URL.

      Making this change depends on your host environment and website setup. Are you using a custom web app or something like WordPress?

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

        There are several ways to do this, but it sounds like you want the files served from /devs/ to appear as root on www.domainname.com.

        1. Rename current root in FTP to /WHATEVER-old/ and copy the contents of the /devs/ folder into the root.
        2. Point the domain root to /devs/ instead of it's current root.
        3. 301 redirect any old page that won't have a matching url on the new site, preferably to the most relevant page content.
        4. Modify the .htaccess file to point to the /devs/ folder.

        Like Ray already said, it is dependent on your hosting setup, CMS or website software, and so on, but setting a root folder is fairly standard. Here's one example from Bluehost.com: http://www.bluehostforum.com/showthread.php?9844-Change-Root-Folder. Your own host should have specific technical documentation.

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

          Hi Ryan, I'm running an ecommerce site (opencart) on the /devs/ folder so will that cause me problems do you think if I just copy the files over to the root?

          If I follow the link you gave me (bluehostforum) it appears all I need to do is add the code in my .htaccess file. Do I still need to move all the files from my /devs/ folder if I tackle this from the .htaccess file code?

          RyanPurkey 1 Reply Last reply Reply Quote 0
          • RyanPurkey
            RyanPurkey @SeoSheikh last edited by

            The nice thing about .htaccess is it's easy to test. Save your current file locally, upload a new one with the changes that you think will make your /devs/ folder the new root, and then test.  If it doesn't work, overwrite the new .htaccess with the old one and determine where you might have gone wrong.  It doesn't involve moving any other files on your server.  Again, depending on your host they might have specific instructions for changing the root folder as well.

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

              Thanks Ryan, I shall give it a go and let you know how I get on.

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

                Hi Ryan, I did this set up but I can't seem to get my 301 redirects to work properly. This is what I have:

                www.foliages.ae now points to www.foliages.ae/devs/

                But when I try and redirect a page to a new one it doesn't work. For example:

                www.foliages.ae/buy-online/artificial-trees-dubai/artificial-olive-trees should point to http://www.foliages.ae/artificial-trees/olive but instead I get http://www.foliages.ae/?_route_=artificial-trees-dubai/artificial-olive-trees

                I have the following .htaccess code in the root folder:

                RewriteEngine on
                RewriteCond %{HTTP_HOST} ^(www.)?foliages.ae$
                RewriteCond %{REQUEST_URI} !^/devs/
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule ^(.*)$ /devs/$1
                RewriteCond %{HTTP_HOST} ^(www.)?foliages.ae$
                RewriteRule ^(/)?$ devs/index.php [L]

                And in my /devs/ folder .htaccess I have:

                1.To use URL Alias you need to be running apache with mod_rewrite enabled.

                2. In your opencart directory rename htaccess.txt to .htaccess.

                For any support issues please visit: http://www.opencart.com

                Options +FollowSymlinks

                Prevent Directoy listing

                Options -Indexes

                Prevent Direct Access to files

                <filesmatch ".(tpl|ini|log)"="">Order deny,allow
                Deny from all</filesmatch>

                SEO URL Settings

                RewriteEngine On

                If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

                RewriteBase /devs/
                RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
                RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteCond %{REQUEST_URI} !..(ico|gif|jpg|jpeg|png|js|css)
                RewriteRule ^([^?]
                ) index.php?route=$1 [L,QSA]

                Additional Settings that may need to be enabled for some servers

                Uncomment the commands by removing the # sign in front of it.

                If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

                1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:

                php_flag register_globals off

                2. If your cart has magic quotes enabled, This may work to disable it:

                php_flag magic_quotes_gpc Off

                3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try

                php_value upload_max_filesize 999M

                4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields

                php_value post_max_size 999M

                5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields

                php_value max_execution_time 200

                6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields

                php_value max_input_time 200

                7. disable open_basedir limitations

                php_admin_value open_basedir none

                redirect 301 /buy-online http://www.foliages.ae
                redirect 301 /buy-online/artificial-trees-dubai/artificial-olive-trees http://www.foliages.ae/devs/artificial-trees/olive

                Any ideas?

                RyanPurkey 1 Reply Last reply Reply Quote 0
                • RyanPurkey
                  RyanPurkey @SeoSheikh last edited by

                  Too bad that didn't work. Your code isn't changing out the URL past "/buy-online" and is appending "?route=" instead.

                  Plus you're getting duplicate content via:
                  http://www.foliages.ae/devs/artificial-trees/olive
                  and
                  http://www.foliages.ae/artificial-trees/olive

                  The help docs on mod_write are here: https://httpd.apache.org/docs/2.2/rewrite/intro.html and they warn, "Rewriting is typically configured in the main server configuration setting (outside any <directory>section) or inside <virtualhost>containers. This is the easiest way to do rewriting and is recommended. It is possible, however, to do rewriting inside <directory>sections or .htaccess files at the expense of some additional complexity. This technique is called per-directory rewrites.

                  The main difference with per-server rewrites is that the path prefix of the directory containing the .htaccess file is stripped before matching in the RewriteRule. In addition, the RewriteBase should be used to assure the request is properly mapped."</directory></virtualhost></directory>

                  You'll have to crack this on your own or hire out for it unless someone else chimes in.

                  SeoSheikh 1 Reply Last reply Reply Quote 0
                  • SeoSheikh
                    SeoSheikh @RyanPurkey last edited by

                    Hi Ryan, I have now since moved the website to the old root folder / instead of /devs/. I have also removed the old .htaccess that redirected my domainname.com to domainname.com/devs/.

                    For some strange reason though I'm still getting the "?route=" whenever i'm doing a new 301 redirect. You can see my htaccess below:

                    1.To use URL Alias you need to be running apache with mod_rewrite enabled.

                    2. In your opencart directory rename htaccess.txt to .htaccess.

                    For any support issues please visit: http://www.opencart.com

                    Options +FollowSymlinks

                    Prevent Directoy listing

                    Options -Indexes

                    Prevent Direct Access to files

                    <filesmatch ".(tpl|ini|log)"="">Order deny,allow
                    Deny from all</filesmatch>

                    SEO URL Settings

                    RewriteEngine On

                    If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/

                    RewriteBase /
                    RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
                    RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteCond %{REQUEST_FILENAME} !-d
                    RewriteCond %{REQUEST_URI} !..(ico|gif|jpg|jpeg|png|js|css)
                    RewriteRule ^([^?]
                    ) index.php?route=$1 [L,QSA]

                    Additional Settings that may need to be enabled for some servers

                    Uncomment the commands by removing the # sign in front of it.

                    If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

                    1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:

                    php_flag register_globals off

                    2. If your cart has magic quotes enabled, This may work to disable it:

                    php_flag magic_quotes_gpc Off

                    3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try

                    php_value upload_max_filesize 999M

                    4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields

                    php_value post_max_size 999M

                    5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields

                    php_value max_execution_time 200

                    6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields

                    php_value max_input_time 200

                    7. disable open_basedir limitations

                    php_admin_value open_basedir none

                    redirect 301 /buy-online http://www.foliages.ae/

                    RyanPurkey 2 Replies Last reply Reply Quote 0
                    • RyanPurkey
                      RyanPurkey @SeoSheikh last edited by

                      Your $1 variable is coming after the '?route=' bit. You can test htaccess code here: http://htaccess.madewithlove.be.

                      1 Reply Last reply Reply Quote 0
                      • RyanPurkey
                        RyanPurkey @SeoSheikh last edited by

                        Also useful: https://github.com/phanan/htaccess.  Cheers!

                        1 Reply Last reply Reply Quote 0
                        • 1 / 1
                        • First post
                          Last post
                        • Discourage search engines from indexing this site AFTER a site launch
                          John.Moz.com
                          John.Moz.com
                          0
                          3
                          437

                        • Maintaining Rank During a Domain Change
                          a_toohill
                          a_toohill
                          1
                          4
                          205

                        • Site Not Rankings After a Few Months
                          davebuts
                          davebuts
                          0
                          7
                          120

                        • Site Getting hacked
                          Xtend-Life
                          Xtend-Life
                          0
                          7
                          119

                        • I have 5 sites each targeting a different service my company offers, should I consolidate to one site or merge to one?
                          MiriamEllis
                          MiriamEllis
                          0
                          5
                          138

                        • Why a site just dropped out of ranks
                          Atomicx
                          Atomicx
                          0
                          4
                          88

                        • Sites Verification Issues
                          spentland
                          spentland
                          0
                          3
                          72

                        • International Site Geolocation Redirection (best way to redirect and allow Google bots to index sites)
                          FedeEinhorn
                          FedeEinhorn
                          0
                          9
                          20.8k

                        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