Changing the sites root folder
-
Hi am in the process of developing my new site domainname.com/devs/ but my current site is still on www.domainname.com/
When the time comes to launch the new site (in devs folder) I want to change the main root folder to this devs folder.
Is there a correct system to do this with as little pain as possible. I know I will need to go through all of my pages and make sure they are 301 redirected to the new folder, but not sure what the correct way to tackle the domain name root folder change.
Any help would be awesome!
Thanks
-
Also useful: https://github.com/phanan/htaccess. Cheers!
-
Your $1 variable is coming after the '?route=' bit. You can test htaccess code here: http://htaccess.madewithlove.be.
-
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/
-
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/oliveThe 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.
-
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/oliveAny ideas?
-
Thanks Ryan, I shall give it a go and let you know how I get on.
-
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.
-
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?
-
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.
- Rename current root in FTP to /WHATEVER-old/ and copy the contents of the /devs/ folder into the root.
- Point the domain root to /devs/ instead of it's current root.
- 301 redirect any old page that won't have a matching url on the new site, preferably to the most relevant page content.
- 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.
-
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?
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
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.
Related Questions
-
Server was banned, now all sites have dropped ranking.
Hi, I'm new here 🙂 I look after half a dozen sites on the one server. Early January three of those Wordpress sites were hacked and reported for phishing. All sites have been cleaned and the report(s) removed but they are all ranking much lower than previously. I also added IP block to the sites to limit the traffic to Australia and New Zealand as these are all local small businesses. I checked IP reputation for the server and it is neutral, with no blacklisting showing. I checked with the hosting company and they have no bans or warnings on the server either. These sites were ranking ok, usually first or second page but they have all dropped down to page 5 or worse now. Is there anything else I should check? I have resubmitted the sites to Google a few days ago. Any guidance greatly appreciated. I a web designer so I know a little about SEO but this is beyond me.
Local Website Optimization | | MarkNWD0 -
IYO, What is the Best Language to Build a Site With and Why? Thanks Catherine Corn
IYO, What is the Best Language to Build a Site With and Why? Thanks Catherine Corn
Local Website Optimization | | CatherineCorn10 -
On what pages of my site should I put schema.org structured markup for an Aggregate Review of a Concrete Construction Contractors work?
I have a concrete contractor that I do a site for. He has many reviews from Home Advisor. So I created a Structured Data Markup using HTML5\. I put the the AggregateReview near the bottom of the About Us page at [http://www.skv-construction.com/about-us.html](http://www.skv-construction.com/about-us.html). Question 1: Should I also put the AggregateReview on the home page, or on specific project pages. Question 2: How will Google use the data now if the About page is NOT searched or displayed in SERPs. Does Google display this markup when and where they want to? Question 3: Siince this is a Local Business, should I embed the AggregateReview within the LocalSearch tag. I passed the Google test as it is for the Aggregate Review! But I have the review wrapped in the HomeAndConstructionBusiness tag. Here is the code: "http://schema.org/HomeAndConstructionBusiness"> # Quality Workmanship w 50 Yrs Experience "http://schema.org/AggregateRating"> 4.37 stars-based on 54 reviews at ["http://www.homeadvisor.com/rated.SKVConstruction.18028291.html"](<a) target="_blank">Home Advisor "http://schema.org/PostalAddress"> 10005 Fair Lane <spam itemprop="addresslocality" union=""></spam> IL 60180 (847) 364 0161 ["http://www.skv-construction.com/contact-us.html"](<a)>Contact Us Price Range: All Jobs Custom; Call for Quote or Visit Web Site Would appreciate any help. This markup is so vague, I can see why few people are using it. Maybe you should do a Video training or extended training on how to's. Vernon Wanner 815-332-8062
Local Website Optimization | | VernonWanner0 -
Local cTLD site not showing up in local SERP
I have 1 website with 2 cTLD. 1 is with .be another .nl. Both are in Dutch and pretty much with the same content but a different cTLD. The problem I have is that the .nl website is showing up in my serp on google.be. So I'm not seeing any keyword rankings for the .be website. I want to be able to see only .nl website serp for google.nl and .be serp on google.be I've already set up hreflang tags since 2-3 weeks and search console confirmed that it's been implemented correctly. I've alsy fetched the site and requested a re-index of the website. Is there anything else I can do? Or how long do I have to wait till Google will update the serp?
Local Website Optimization | | Jacobe0 -
Why a site just dropped out of ranks
I have a site i am working on link It was ranking fairly well and then I added content to the homepage to better optimize it for the keywords it was already ranking for. Ever since I did that the entire site is no longer ranking well. Thoughts?
Local Website Optimization | | Atomicx0 -
Moving back to .com site
Hi Many thanks for all the input we have had from the Moz expert team here. We have had some great thoughts and we have finally decided that we need to move our site to an new provider and to go back to one single .com site for all our global traffic, as we cannot get round possible duplicate pages as we cannot use canonical nor alternate links with our current website provider and this has meant a big rethink in the last couple of weeks. We where running two sites, .com which has been running for 7 years and a .co.uk site which was dormant since 2007 until 2013 and used from last year to serve our local customers. Domain Authority for .com 19 and 23 for .co.uk Our new site will serve 3 currencies so we can offer £ $ & € without the need for duplicate pages or local pages. We plan but are flexible about using a 301 from the .co.uk site to the dot com. and have enough data to ensure we can do all 301 redirects at page level from our current .co.uk site to our new .com site. Can anyone provide any SEO tips on ensure we grow our rankings when we make the switch in about 3 weeks. Many thanks Bruce
Local Website Optimization | | BruceA2 -
Duplicate content question for multiple sites under one brand
I would like to get some opinions on the best way to handle duplicate / similar content that is on our company website and local facility level sites. Our company website is our flagship website that contains all of our service offerings, and we use this site to complete nationally for our SEO efforts. We then have around 100 localized facility level sites for the different locations we operate that we use to rank for local SEO. There is enough of a difference between these locations that it was decided (long ago before me) that there would be a separate website for each. There is however, much duplicate content across all these sites due to the service offerings being roughly the same. Every website has it's own unique domain name, but I believe they are all on the same C-block. I'm thinking of going with 1 of 2 options and wanted to get some opinions on which would be best. 1 - Keep the services content identical across the company website and all facility sites, and use the rel=canonical tag on all the facility sites to reference the company website. My only concern here is if this would drastically hurt local SEO for the facility sites. 2 - Create two unique sets of services content. Use one set on the company website. And use the second set on the facility sites, and either live with the duplicate content or try and sprinkle in enough local geographic content to create some differential between the facility sites. Or if there are other suggestions on a better way to handle this, I would love to hear any other thoughts as well. Thanks!
Local Website Optimization | | KHCreative0 -
Bing ranking a weak local branch office site of our 200-unit franchise higher than the brand page - throughout the USA!?
We have a brand with a major website at ourbrand.com. I'm using stand-ins for the actual brandname. The brand is a unique term, has 200 local offices with sites at ourbrand.com/locations/locationname, and is structured with best practices, and has a well built sitemap.xml. The link profile is diverse and solid. There are very few crawl errors and no warnings in Google Webmaster central. Each location has schema.org markup that has been checked with markup validation tools. No matter what tool you use, and how you look at it t's obvious this is the brand site. DA 51/100, PA 59/100. A rouge franchisee has broken their agreement and made their own site in a city on a different domain name, ourbrandseattle.com. The site is clearly optimized for that city, and has a weak inbound link profile. DA 18/100, PA 21/100. The link profile has low diversity and generally weak. They have no social media activity. They have not linked to ourbrand.com <- my leading theory. **The problem is that this rogue site is OUT RANKING the brand site all over the USA on Bing. **Even where it makes no sense at all. We are using whitespark.ca to check our ranking remotely in other cities and try to remove the effects of local personalization. What should we do? What have I missed?
Local Website Optimization | | scottclark0