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
-
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 -
Ecommerce Site Structure -- "/our_locations" page: helpful or harmful?
Hello! We are a retailer with brick and mortar stores in different cities. We have a website (ourbusiness.com), which includes a blog (ourbusiness.com/blog) and a separate ecommerce site for each store in subfolders (ourbusiness.com/Boston-store and ourbusiness.com/Atlanta-store). NB: We do this for non-business reasons and have no choice. So, this is not like REI (for example) or other stores with lots of locations but one central ecommerce operation. Most experts seem to recommend a site structure that echoes REIs. IE: a home page principally devoted to ecommerce (rei.com) includes an Our Locations-type page (rei.com/stores) which links to local store pages like (rei.com/stores/fresno) I understand how this would help REI, since their homepage is devoted to ecommerce and they need a store locator page that doesn't compete with the shopping experience. But since we can't send people to products directly from our home page, is there any reason for us not to put the store locator function right on the home page? That is, is there any reason in our case to prefer (A) ourbusiness.com/our_locations/Boston_store over (B) ourbusiness.com/Boston-store? As i see it, the extra page (/our_locations/) could actually hurt, as it puts products one click further away from customers, and one link deeper for bots. On the other hand, it may make the multi-store structure clearer to bots (and maybe people) and help us in local search. Finally, would it make a difference if there were 10 stores vs 2? Thanks for any thoughts!
Local Website Optimization | | RankAmateur...1 -
I've submitted my site to google search console, and only 6 images of 89 images have been indexed in 2 weeks. Should I be worried?
I've submitted my site to google search console, and only 6 images of 89 images have been indexed in 2 weeks. Should I be worried? My site is http://bayareahomebirth.org Images are a pretty big part of this site's content and SEO value. Thanks for your help!
Local Website Optimization | | mattchew0 -
Does multiple sites that relate to one company hurt seo
I know this has been asked and answered but my situation is a little different. I am a local electrical contractor. I specialize in a service and not a product. Competition is high in the local market due to the other electrical contractors that have well seasoned sites with very good DA/PA. Although new to the web I am not new to the trade. Throughout years almost back to the AOL dialup days I have been collecting domain names for this particular purpose. Now I want to put them to good use. Being an electrical contractor, there are many different facets of work and services we provide. My primary site is empireelec.com A second site I threw online overnight with minimal content is jacksonvillelightingrepair.com. Although it is a fresh site, there is minimal content and I have put almost zero effort in to it. It appears to be ranking for keywords a lot quicker. That leads me to believe I should utilize my other domain jacksonvillefloridaelectrician.com and target just the keyword Jacksonville Florida Electrician. It leads me to believe I should use jacksonvillebeachelectrician.com for targeting electricians in jacksonville beach. And again with jacksonvilleelectricianservice.com I can provide a unique phone number for each site. Am I going about this all wrong? Everything I read says no,no,no but I feel my situation is a little more unique.
Local Website Optimization | | empireelec1 -
How can my categories rank for my different branches? Tidied site up but now local rankings are worse
Dear Mozzers , I am wondering if someone could please help with some advice and assistance on the following for our Tool hire site: Basically I like to know how we can rank for our categories for our different branch locations ?. We have a branch finder page and separate branch pages but I do not know if I should have an internal link from all our branch pages to all my different categories or not or is google clever enough to know that I have x locations and x categories and I should rank all the categories in all the locations. I think my site structure is fairly straightforward and on the face of it similar to what others do who have multiple branches . For example I enclose a link to 2 of our categories - carpet cleaner hire category and a floor sander hire category carpet cleaner category - http://goo.gl/cMyS4i floor sander category - http://goo.gl/4ipUyA Heres a link to our Branch Finder - http://goo.gl/UyTQdK Heres a link to one of our Branches for example - Bristol Branch - http://goo.gl/9TXHTK And heres our link to our google plus Bristol page - google plus bristol branch page - https://goo.gl/h0IwAK . We have link from our bristol page going to the bristol google plus page and visa versa. Currently within our internal linking structure there is No direct link on the branch pages to the categories ?. Is this something we need to do or not necessary ?. - If we do it , then it may mess up or confuse the page as I someone need to get all the category links on the branch pages ? We have lots of good unique content , lots of citations for our branches and categories etc but we just don't seem to rank at all well for any of our categories in local search. For example if somene was to search for - Carpet cleaner hire "City Name " or Floor sander hire "City Name" (City name being where our branches are). We dont rank very well for most of our cities. Even without putting the city name in we dont rank to well in local search. We used to have individual pages for our categories in each of the cities we have branches with unique content on all and these did rank quite well in a few cities but never top 3 in most and we got rid of these last month (start of Oct) as I was told that google may see this as quite spammy or doorway pages if I have a carpet cleaner hire Bristol page or a floor sander hire Bristol page etc ?.. All my location landing pages now just 301 back to the appropriate category. I am wondering if getting rid of these landing pages was a good idea as by tidying things up , I've seemed to have lost my local rankings for my cities. Can someone please advise if what I did was right and what else I should look at doing ?> Could it be an internal linking issue I need to sort ? Any assistance much appreciated.
Local Website Optimization | | PeteC12
thanks
Pete0 -
Can a Find Us Link suffice as the NAP in footer of site?
I understand the need for NAP in the website for citation sourcing / local ranking purposes, etc. Is it possible to use a linking anchor text such as "Find Us" that can link to the Contact Page of the site that does list the street address? Or should it link to the google places listing? The client basically wants to "hide" the NAP, but keep the power of the local listing. Can this be done? Any suggestions? Or an example of website that does this successfully?
Local Website Optimization | | cschwartzel1 -
Multilingual site making new URLs, how to preserve SEO juice?
Hello! My site currently serves content in german and english, however without having separate URLs (it depends on Accept-Language and has a submitform for changing language based on set cookies). The site appears extremely well in the search engine, with many keywords ranking at #1-10. They appear on the german and english google search, with the first one bringing the best results. It's however the english site that appears in the results. I want to change to a better approach by having subdirectories for each language, as I'm extending the site, I know how to do this but I have found -nowhere- any infos on how to preserve my search engine ranks? If I keep the english version as homepage and send german visitors to /de/, might this kill my position in the german search engine which is very important, as the new frontpage under /de/ would become more relevant and the english one maybe less? Or should I keep the german version the default one and send english visitors elsewhere? What happens with my search positions, if I have no side on the / but visitors are always send to either /en/ or /de/? Every help is greatly appreciated, as I found a lot of articles everywhere on how to make a multilingual site, but nowhere anything on how it affects current search results.
Local Website Optimization | | innovacy0 -
Sites Verification Issues
We have a group of automotive dealerships by a website provider that causes issues when trying to verify our sites. Because they use Analytics for their data program, they install a code into our websites-stopping us from doing so properly in our back end. We also cannot verify ourselves in webmasters or adwords. We can't actually "own" any of our sites since they run a java query script from within the website. They also do not allow the use of iframes or scripts, so we can't even use the container to verify these sites. Any help or insight would be greatly appreciated as I am sure there is some way to break this to get our data and be verified.
Local Website Optimization | | spentland0