Jump to content

[solved] Move prestashop from subfolder to root


Recommended Posts

Hello

 

Im new to PS and am working on my first installation and setup using the latest stable version. I installed PS in a subfolder (www.domain.com/prestashop) but now I want to move it to the root folder so it will be www.domain.com

 

How do I do this?

 

Is there anything I can mess up in the process?

 

Some config file to edit?

 

 

Thanks

-midrik

Link to comment
Share on other sites

one sure fire method is to backup your DB and product images FIRST<<
then move your entire folder up a level. See if it's working. If not, move it back again. Do another install of your prestashop, upload your image files and insert the DB entries.

Link to comment
Share on other sites

why not leave in the sub?

just edit your .htaccess file in the root dir and put this in it:
(you need to replace prestashop by your own subdir and mysite.com by your own domainname obviously)

# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.

# Do not change this line - RewriteEngine on
RewriteEngine on

# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/prestashop/

# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /prestashop/$1

# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ prestashop/index.php [L]


  • Like 5
Link to comment
Share on other sites

  • 9 months later...
  • 9 months later...

Michaeld - sorry to just in like this - i have a question on this topic.

I used your htaccess script and it works great thanks for sharing.

Is there anyway to not have the address bar show the /folder when search has been done. At the moment my shop is in a folder called /shop. When i type mywebsite.com into the address bar. It shows mywebsite.com/shop/index.php also happens when typing www.mywedsite.com
The other thing is canonical where the url always shows either www.mywebsite.com or mywebsite.com

I think this solution would be helpful for everyone along with your method above.

Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...
why not leave in the sub?

just edit your .htaccess file in the root dir and put this in it:
(you need to replace prestashop by your own subdir and mysite.com by your own domainname obviously)
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.

# Do not change this line - RewriteEngine on
RewriteEngine on

# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/prestashop/

# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /prestashop/$1

# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ prestashop/index.php [L]




This worked perfectly thank you
Link to comment
Share on other sites

  • 3 weeks later...
why not leave in the sub?

just edit your .htaccess file in the root dir and put this in it:
(you need to replace prestashop by your own subdir and mysite.com by your own domainname obviously)
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.

# Do not change this line - RewriteEngine on
RewriteEngine on

# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/prestashop/

# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /prestashop/$1

# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ prestashop/index.php [L]




I also have my prestashop in /root/prestashop dir and I don't want to have my web address www.maindomain.com/prestashop, but only www.maindomain.com. And I would like to keep prestashop dir (don't want to move all content to root dir). Will above solution work with v1.4.0.17? Which are all the files needed to be in root folder (beside .htaccess)? Thank you!
Link to comment
Share on other sites

  • 2 months later...

I might be missing the point here (as I am no expert). Is there any reason this would not work:

1. Have your live PS files in a sub directory (e.g. /version_1 ). On your host, set the websites home (or destination) directory to the sub directory. Then in PS preferences-->URL setup, set the 'PS directory' to "/" (thus ensuring the sub directory is not displayed in the URL on your browser).

2. If you have a development version, place this in a sub folder within the live folder (i.e. /version_1/version_2 ). In the development PS preferences-->URL setup, set the 'PS directory' to "/version_2/".

3. When your new version is ready, just:
- copy directory "/version_2" up a level
- change the PS preferences-->URL setup, set the 'PS directory' to "/"
- on your host, change the websites home directory to /version_2

4. If you have any problems with your new site, you can just change the website home directory back to /version_1 and you are back up and running.

Link to comment
Share on other sites

  • 2 weeks later...

Hi, this is my first time using PS and i am building my online store, what i want to do is have a home screen with a click to enter button at the main domain - www.stickerwerkz.com and have my prestashop at www.stickerwerkz.com/shop

The shop is currently the main domain, as soon as you go to the site. How do i do this in simple terms please!

Thanks for any help :)

Link to comment
Share on other sites

  • 2 months later...

why not leave in the sub?<br/><br/>just edit your .htaccess file in the root dir and put this in it:<br/>(you need to replace prestashop by your own subdir and mysite.com by your own domainname obviously)<br/>

<br/># Copy and paste the following code into the .htaccess file<br/># in the public_html folder of your hosting account<br/># make the changes to the file according to the instructions.<br/><br/># Do not change this line - RewriteEngine on<br/>RewriteEngine on<br/><br/># Change yourdomain.com to be your main domain.<br/>RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$<br/><br/># Change 'subfolder' to be the folder you will use for your main domain.<br/>RewriteCond %{REQUEST_URI} !^/prestashop/<br/><br/># Don't change this line.<br/>RewriteCond %{REQUEST_FILENAME} !-f<br/>RewriteCond %{REQUEST_FILENAME} !-d<br/><br/># Change 'subfolder' to be the folder you will use for your main domain.<br/>RewriteRule ^(.*)$ /prestashop/$1<br/><br/># Change yourdomain.com to be your main domain again.<br/># Change 'subfolder' to be the folder you will use for your main domain<br/># followed by / then the main file for your site, index.php, index.html, etc.<br/>RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$<br/>RewriteRule ^(/)?$ prestashop/index.php [L]<br/><br/><br/>

 

I tried this solution (thanks for posting) but now my database isn't working. No photos from it appear and the product pages don't work.

 

Any ideas?

 

>>>

Update:

WHen I turn URL re-write off the database works fine from subfolder location.

Link to comment
Share on other sites

I'm a genius. Made a backup of the original re-writing script Presta generated in my old .htaccess file. Used that then updated the file names to include new sub-directory. Now it's working.

 

Has to be said the .htaccess auto-generate in the back office did not work. Very annoying. If I had not have made that backup I would not have been able to fix this.

Link to comment
Share on other sites

Ah, now I cant even create a fresh install. Updating Prestashop is a complete nightmare. The updated version in my sub-folder works but very slowly when loading categories. So I need to create a new version but the databases wont even connect now when trying a fresh install. Starting to hate prestashop.

Link to comment
Share on other sites

why not leave in the sub?

just edit your .htaccess file in the root dir and put this in it:

(you need to replace prestashop by your own subdir and mysite.com by your own domainname obviously)

# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line - RewriteEngine on
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
# Change 'subfolder' to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/prestashop/
# Don't change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change 'subfolder' to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /prestashop/$1
# Change yourdomain.com to be your main domain again.
# Change 'subfolder' to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$
RewriteRule ^(/)?$ prestashop/index.php [L]

 

I might be missing the point here (as I am no expert). Is there any reason this would not work:

1. Have your live PS files in a sub directory (e.g. /version_1 ). On your host, set the websites home (or destination) directory to the sub directory. Then in PS preferences-->URL setup, set the 'PS directory' to "/" (thus ensuring the sub directory is not displayed in the URL on your browser).

2. If you have a development version, place this in a sub folder within the live folder (i.e. /version_1/version_2 ). In the development PS preferences-->URL setup, set the 'PS directory' to "/version_2/".

3. When your new version is ready, just:

- copy directory "/version_2" up a level

- change the PS preferences-->URL setup, set the 'PS directory' to "/"

- on your host, change the websites home directory to /version_2

4. If you have any problems with your new site, you can just change the website home directory back to /version_1 and you are back up and running.

 

Combine 2 solution above on 1.4.2.5 + siteground hosting redirect from root too subdirectory and hide subdirectory is work great.

 

I edit only .htaccess on web hosting root (/public_html/) and let's presta back office automatic generate .htaccess with URL friendly on /public_html/presta1425

 

Any questions are welcome (Thai/English lang.)

Link to comment
Share on other sites

  • 2 weeks later...

I just finished all my setup+configuration inside a "catalog" folder and just successfully copied it all to the root of my public_html directory. My Presta Version is 1.4.4.1.

 

Some/most of this is a repeat of above posts but I see they date back in some cases 2009 so here's the summary of what I did:

 

1. Using file manager in CPanel on my server I made a compressed file of the inside of my "Catalog" folder (the entire Presta website I made started in "www.mysite/Catalog/") called "catalog.zip".

DO NOT just rightclick on "Catalog" folder and compress it. Doing this will create yet another "catalog" folder = exactly what you already have!!!! Go INTO/INSIDE the folder, then select all the sub-folders and files, and then right click - compress.

 

2. A zip file will appear now inside your current shop's root.

I moved that zip file holding my entire Presta shop to the root of my server's public_html.

You could download the zipfile, then upload it to your public_html root if you prefer.

 

3. Still in CPanel File Manager move to your root of public_html.

unzip/uncompress it from within your root of public_html.

 

Now you still have your working copy inside "www.yoursite/Catalog/" and ALSO the second copy to now get activated.

This leaves you some safety until you see all works well.

 

4. Still in CPanel File Manager in your new root version of your shop, go into the folder called "Config".

Download or edit online if you want the "settings.inc.php" changing:

 

from define('__PS_BASE_URI__', '/your-old-presta-subfolder-name/');

 

to

 

define('__PS_BASE_URI__', '/');

 

Save or overwrite the file.

 

5. Now try going into your admin back office through the root version www.mysite/admin/.

It should allow you inside BUT you're not done yet.

 

6. Now go to Preferences -->SEO & URLs. Scroll way down and make sure PS directory only shows /

7. Go to Tools ---> Generators and click on the "Generate htaccess" then "Generate robots.txt" to sync those files.

 

If you skip the last step your front office site will still point to the old locations and the robot text will as well.

 

8. Go into "Modules" and fix any payment areas that require your specific URLs if required.

9. Go to PayPal.com and/or Google.com if you use them as payment gateways and again revise their settings URLs to match your new one.

 

After testing your new rooted site enough you could delete the old one or maybe just set it to "catalog mode" in Preferences --> Products to make it there for backup but not usable for ordering.

 

I will delete mine after about 2 weeks of testing my root one.

  • Like 1
Link to comment
Share on other sites

  • 2 months later...

Bigbear's comment was spot on. I have this up and running (although my dev version is in a totally different subdirectory) - works like a charm.

 

One of the keys is to edit .htaccess in the /public_html/ and leave the .htaccess in the /prestashop installation.

 

Thanks BigBear!

  • Like 2
Link to comment
Share on other sites

  • 4 months later...

Thank you tozama for a great walk thru.

I only have one (big) problem, my index site can´t be found, error 404.

 

Do you, or anyone else, have any suggestions?

Can there be a link I missed to rewrite?

I use Prestashop 1.4.6.2 and the Matrice theme.

 

Regards

Weronicha

www.handelshusetkallan.se

 

 

 

Edit: Firefox was playing with me, everything is working fine now. :D

Edited by Källan (see edit history)
Link to comment
Share on other sites

  • 5 months later...

Hello Tozama!

 

I just finished all my setup+configuration inside a "catalog" folder and just successfully copied it all to the root of my public_html directory. My Presta Version is 1.4.4.1.

(...)

I will delete mine after about 2 weeks of testing my root one.

 

I've been searching for such step by step clearly described action of moving presta shop. THANK YOU!

 

Dear Tozama, I have just one question - will this work with PrestaShop 1.5?

 

Thank you in advance for the update on this topic.

Best, Miki

Link to comment
Share on other sites

Bigbear's comment was spot on. I have this up and running (although my dev version is in a totally different subdirectory) - works like a charm.

 

One of the keys is to edit .htaccess in the /public_html/ and leave the .htaccess in the /prestashop installation.

 

Thanks BigBear!

 

This is basically what I did, have my shop in /new after an upgrade and redirect my domain to that subdirectory. however, what I do not quite get is why I would need to edit my htaccess? if that one is in /new as well, wouldn't it be pulled automatically and also be tricked by the redirect that it is in the main folder (instead of the subfolder /new)?. or will the htaccess still be pulled from the main folder despite redirecting my whole server to /new?

Edited by Pippo3000 (see edit history)
Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

I have the same problem, running 1.5.3.1... I've moved my files from root/shop to root and modified the settings under SEO.

My back office works fine but every call to database is frozen on the website, can not register a user, cannot add a product to cart, it kills me...

settings.inc.php file doesn't have the hard writen path anymore...

The worth is I've tried to reinstall the all thing from scratch and it still doesn't work.

.htaccess still has all the right values... I'm lost.

Can anyone help with this please?

Link to comment
Share on other sites

  • 7 months later...

why not leave in the sub?

 

just edit your .htaccess file in the root dir and put this in it:

(you need to replace prestashop by your own subdir and mysite.com by your own domainname obviously)

# Copy and paste the following code into the .htaccess file# in the public_html folder of your hosting account# make the changes to the file according to the instructions.# Do not change this line - RewriteEngine onRewriteEngine on# Change yourdomain.com to be your main domain.RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$# Change 'subfolder' to be the folder you will use for your main domain.RewriteCond %{REQUEST_URI} !^/prestashop/# Don't change this line.RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# Change 'subfolder' to be the folder you will use for your main domain.RewriteRule ^(.*)$ /prestashop/$1# Change yourdomain.com to be your main domain again.# Change 'subfolder' to be the folder you will use for your main domain# followed by / then the main file for your site, index.php, index.html, etc.RewriteCond %{HTTP_HOST} ^(www.)?mysite.com$RewriteRule ^(/)?$ prestashop/index.php [L]

 

Hi there, I'm trying to run prestashop from a subfolder (for obvious reasons - so we don't make a mess in the root folder) but show the users the shop as if it was installed in the root folder.

 

And I'm having the fallowing problem:

 

I've fallowed the above instructions (which by the way can be found in more detail on this site: http://dobetterit.com/prestashop-in-sub-folder/ ) and created the .htaccess in the root folder.

 

If I just access the domain is all fine appart from the fact that the .htaccess file from the root folder doesn't do anything else other than re-direct you to the /prestashop folder where we've installed the shop which I imagine is not really resolving our scope which is running the site as if it was installed under the root directory when actually is in a subdirectory.

 

However if I fallow the instructions fully from the website I've mentioned above (and that is also changing the Base URI in Preferences->SEO & URLs from:

 

Base URI: /prestashop/

to

Base URI: /

 

then we do achieve our scope in the front end: The shop URLs won't be showing the subfolder in them anymore.  So we would get:

 

mysite.com/1-acategory/

instead of

mysite.com/prestashop/1-acategory/

 

However now we have a new problem: Going into Catalogue->Products->Product page our Product page will not display any content.

 

Print screen attached:

product-page-error.png

 

Any one know any work around for this?

 

Thanks.

 

PS: Forgot to add the version of Prestashop used:

 

Server information

Server information: Linux #1 SMP Tue Mar 27 11:42:17 MSD 2012 x86_64

Server software version: Apache

PHP version: 5.3.18

Memory limit: 128M

Max execution time: 60

Database information

MySQL version: 5.5.28

MySQL engine: MyISAM

Tables prefix:

Store information

Prestashop version: 1.5.3.1

Shop URL: http://otisjaxonsilverjewellery.com/store/

Current theme in use: otis_jaxon

Mail configuration

Mail method: You are using the PHP mail() function.

Your information

Your web browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36

Edited by pali (see edit history)
Link to comment
Share on other sites

  • 2 months later...
I also used the htaccess solution and URI ="/"over a 1.5.6.1 version. But is not working well:

 
Somehow  redirections  with "www." doesn´t work right. I get this redirections:
 
 
 
http://mydomain.com               works: redirects to                      root/subfolder/index.php
http://mydomain.com/en           works
 
http://www.mydomain.com/               shows 404page:                      http://mydomain.com/index.php?
http://www.mydomain.com/en             shows 404page:                      http://mydomain.com/index.php?controller=404
 
Edit:

Solved:
I study .htaccess manual, and checked all the possibilities of my hosting. Finally was just that I had not the "www...." URL   in the shop configuration in Advanced parameters>Multisite > Shop URLs
Edited by palermuke (see edit history)
Link to comment
Share on other sites

  • 3 years later...

Hi I have installed prestashop in a sub-folder

www.mydomain.com/store so the visitors have to enter the whole url to acces the prestashop. I dont want prestashop to be in the root domain.

I found this rule for htaccess and works well

RewriteEngine on` RewriteCond %{HTTP_HOST} ^(www.)?mydomain.ee$RewriteCond %{REQUEST_URI} !^/prestashop_subdir/RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /prestashop_subdir/RewriteCond %{HTTP_HOST} ^(www.)?mydomain.ee$RewriteRule ^(/)?$ prestashop_subdir/index.php [L]

so now with this settings my visitors access the store using www.mydomain.com (they redirected to the sub-folder)

BUT on the addres bar appear (they see) www.mydomain.com/store

I just want that my visitors access www.mydomain.com access the store automatically, but dont see the store subfolder on the address bar. (where the prestashop is installed)

example:

www.mydomain.com (visitor enter on address bar) they be redirected to the store so can access it but on the url they can still see www.mydomain.com

PD. I copied the htaccess and index.php from prestashop sub-folder installation to the domain (www.mydomain.com)

Link to comment
Share on other sites

  • 4 years later...
On 1/10/2014 at 1:40 PM, palermuke said:
I also used the htaccess solution and URI ="/"over a 1.5.6.1 version. But is not working well:

 
Somehow  redirections  with "www." doesn´t work right. I get this redirections:
 
 
 
http://mydomain.com               works: redirects to                      root/subfolder/index.php
http://mydomain.com/en           works
 
http://www.mydomain.com/               shows 404page:                      http://mydomain.com/index.php?
http://www.mydomain.com/en             shows 404page:                      http://mydomain.com/index.php?controller=404
 
Edit:

Solved:
I study .htaccess manual, and checked all the possibilities of my hosting. Finally was just that I had not the "www...." URL   in the shop configuration in Advanced parameters>Multisite > Shop URLs

We have added www.example.com configuration in the shop configuration in Advance Parameters>Multisite>Shop URLs>Domain

when visited the url www.example.com it redirects to https://www.example.com/en/   404 Error

Is there any solution?

Link to comment
Share on other sites

ps_configuration table need to be updated for the correct path of the website from www.example.com/shop to www.example.com

both HTTP and HTTPS URLs.

The .htaccess file needs to be regenerated for the new website path and Clear cache files.

I did in past by doing the above steps and it works fine.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...