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
-
Leveraging the authority of a blog to boost pages on a root domain.
Hi! Looking for some link building advice. For some background, I work for a company that has over 100 locations across the US. So we are deeply involved with local SEO. We also do a ton of evergreen/ national SEO as well and the spectrums are widely different for the most part. We also have a very successful blog in our industry. It really is an SEO’s dream. I do not even need to worry about a link strategy for this because it just naturally snatches them up. I’m trying to find some unique ways to utilize the blog to boost pages on my main root domain, more specifically, at the local level. It is really hard, besides the standard methods for local link building, to get outside sources to link to our local office pages. These pages are our bread and butter, and the pages we need to be as successful as possible. In every market we are in, we are at a disadvantage because we have one page to establish our local footprint and rank, compared to domains that have their entire site pointed at that local area we are trying to rank in. I’ve tried linking to local office pages from successful blog posts to attempt to pass link juice to the local pages, but I haven’t seen much in terms of moving the needle doing this. Are there any crafty ideas on how I can shuffle some internal linking around to capitalize on the blog’s authority to make my local pages rank higher in their markets? Thank you! -Ben
Local Website Optimization | | Davey_Tree0 -
International Sites
Hi Guys Just wanting to get some feedback on best practices for international website. The main website is a .co.uk there looking to target France & Belgium. The web hosting is UK based. Do we replicate the UK site and translate to local language but use a .fr domain and have 3 versions of the websites on 3 separate domains? or do just use the co.uk with french & Belgium translation have pages related to those countries? Any assistance will be appreciated
Local Website Optimization | | Cocoonfxmedia0 -
Site Audit: Indexed Pages Issue
Over the last couple of months I've been working through some issues with a client. One of my starting points was doing a site Audit. I'm following a post written by Geoff Kenyon https://moz.com/blog/technical-site-audit-for-2015 . One of the main issues of the site audit seems to be that when I run a "site:domain.com" query in Google my homepage isn't the first page listed in fact it isn't listed in this search when I go through all of the listings. I understand that it isn't required to have your homepage listed first when running this type of query, but I would prefer it. Here are some things I've done I ran another query "info:homepage.com" and the home page is indexed by Google. When I run a branded search for the company name the home page does come up first. The current page that is showing up first in the "site:domain.com" listing is my blog index page. Several months back I redirected the index.php page to the root of the domain. Not sure if this is helping or hurting. In the sitemap I removed the index.php and left only the root domain as the page to index. Also all interior links are sent to the root, index.php has been eliminated from all internal links everything links to root The main site navigation does not refer to the "Home" page, but instead my logo is the link to the Home page. Should I noindex my blog/index.php page? This page is only a compilation of posts and does not have any original content instead it actually throws up duplicate content warnings. Any help would be much appreciated. I apologize if this is a silly question, but I'm getting frustrated/ annoyed at the whole situation.
Local Website Optimization | | SEO_Matt0 -
Understand how site redesign impacts SEO
Hi everyone, I have, what I think, is kind of a specific question, but hoping you guys can help me figure out what to do. I have a client that recently changed their entire website (I started working with them after it happened, so I can't comment on what the site was like as far as content was before). I know they were using a service that I see a lot of in the service industry that aim to capitalize on local business (i.e. "leads nearby" or "nearby now") by creating pages for each targeted city and I believe collecting reviews for each city directly on the website. When they redesigned their website, they dropped that service and now all those pages that were ranking in SERPs are coming back as 404s because they are not included in the new site (I apologize if this is getting confusing!) The site that they moved to is a template site that they purchased the rights to from an already successful company in their same industry, so I do think the link structure probably changed, especially with all of the local pages that are no longer available on the site. Note: I want to use discretion in using company names, but happy to share more info in a private message if you'd like to see the sites I am talking about as I have a feeling that this is getting confusing 🙂 Has anyone had experience with something like this? I am concerned because even though I am targeting the keywords being used previously to direct content to the local pages to new existing pages, traffic to the website has dropped by nearly 60% and I know my clients are going to want answers-- and right now, I only have guesses. I am really looking forward to and so greatly appreciate any advice you might be able to share, I'm at a bit of a loss right now.
Local Website Optimization | | KaitlinNS0 -
I have 5 sites each targeting a different service my company offers, should I consolidate to one site or merge to one?
I run a photo booth company and have a site for each service I offer. Are smaller sites that are SEO for each service stronger than just having pages for each service on one mother site?thanks,
Local Website Optimization | | hashtagltd0 -
Schema for same location on multiple sites - can this be done?
I'm looking to find more information on location/local schema. Are you able to implement schema for one location on multiple different sites? (i.e. - Multiple brands/websites (same parent company) - the brands share the same location and address). Also, is schema still important for local SEO? Thank you in advance for your help!
Local Website Optimization | | EvolveCreative0 -
Single sites per location as well as group site. Should we get rid of single sites & only keep group site.
Currently we have several single sites for each of our dealership locations as well as an automotive group site linking to each location(dealership) website. Currently there is no landing page for each location on the group site. To save money we were looking into beefing up our group site and getting rid of our individual location sites. 301 redirecting them to location landing pages on the group site website. Each site has about the same authority including the group site. Each dealership location resides in the same province(state) but some locations are a 7hour drive apart so not all within the same vicinity. I want to ensure we continue to rank well in each location. I won't be able to include all geographic locations in the title tag on the homepage of the group site due to the character restrictions. What would you recommend? Keeping the individual websites per dealership location OR focusing solely on a group website. I need to ensure we continue to rank well in each city where each dealership resides. Thanks for any recommendations! It's greatly appreciated. Thanks for everyone's thoughts & opinions.
Local Website Optimization | | DCochrane1 -
Single Site For Multiple Locations Or Multiple Sites?
Hi, Sorry if this rambles on. There's a few details that kind of convolute this issue so I'll try and be as clear as possible. The site in question has been online for roughly 5 years. It's established with many local citations, does well in local SERPs (working on organic results currently), and represents a business with 2 locations in the same county. The domain is structured as location1brandname.com. The site was recently upgraded from a 6-10 page static HTML site with loads of duplicate content and poor structure to a nice, clean WordPress layout. Again, Google is cool with it, everything was 301'd properly, and our rankings haven't dropped (some have improved). Here's the tricky part: To properly optimize this site for our second location, I am basically building a second website within the original, but customized for our second location. It will be location1brandname.com/secondcity and the menu will be unique to second-city service pages, unique NAP on footer, etc. I will then update our local citations with this new URL and hopefully we'll start appearing higher in local SERPs for the second-city keywords that our main URL isn't currently optimized for. The issue I have is that our root domain has our first city location in the domain and that this might have some negative effect on ranking for the second URL. Conversely, starting on a brand new domain (secondcitybrandname.com) requires building an entire new site and being brand new. My hunch is that we'll be fine making root.com/secondcity that locations homepage and starting a new domain, while cleaner and compeltely separate from our other location, is too much work for not enough benefit. It seems like if they're the same company/brand, they should be on the same sitee. and we can use the root juice to help. Thoughts?
Local Website Optimization | | kirmeliux0