Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to Move Store Home Page to Root without Moving Store?


ErichStauffer

Recommended Posts

I have a site where the store is at /store and the homepage is a separate install (Wordpress) at root (/).

 

How can I make the home page of the store be at root while leaving the store files at the directory /store?

 

Reason: the site has been this way for a long time and moving the store directory would break links on the web.

 

Thanks,

 

Erich

Link to comment
Share on other sites

Hi, I am not 100% sure on this, but believe this is how to do it. Please make back up of any files you change or plan to overwrite before doing anything!

 

In order to also set up your main domain to use a subdirectory on your hosting account you will need to set up a redirect in the .htaccess file in the public_html folder so that the server knows that any request for your main domain will be redirected to a subdirectory on public_html.

 

Modifying the .htaccess
 
The following code will need to be added to the .htaccess file in the public_html folder of your hosting account. You will need to insert the following code block and make modifications as noted in the (#) comments.
 
You will need to change the two instances of example.com to your domain, and the three instances of subdirectory to the folder where you want your site.
 
# .htaccess main domain to subdirectory redirect 
# Do not change this line. 
RewriteEngine on 
# Change example.com to be your main domain. 
RewriteCond %{HTTP_HOST} ^(www.)?example.com$ 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteCond %{REQUEST_URI} !^/subdirectory/ 
# Don't change the following two lines. 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
# Change 'subdirectory' to be the directory you will use for your main domain. 
RewriteRule ^(.*)$ /subdirectory/$1 
# Change example.com to be your main domain again. 
# Change 'subdirectory' to be the directory 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.)?example.com$ 
RewriteRule ^(/)?$ subdirectory/index.php [L]
 
Visitors to your Web site will not be able to tell that your main domain is using a subdirectory, they will still see the Web site address as http://www.example.com/page.html.
Link to comment
Share on other sites

STOP! What are you trying to accomplish here? As I understand it, you have a working WordPress installation in / and a working osCommerce store in /store. Are you getting rid of the WordPress installation, and just going to have the store? In that case, you can use .htaccess to invisibly redirect visitors to / over to /store. It could be as simple as

RewriteEngine On
RewriteCond  %{REQUEST_URI}  !^/store
RewriteRule  ^(.*)$  /store/$1

Give that a try if the other way Leslie gave you doesn't work.

 

If you plan to keep your WP installation, how do you intend to get to it if / is redirected to /store? Are you moving the WP installation, in which case, links/bookmarks to it will likely break?

 

Note that currently, your store passes through /.htaccess (before it gets to /store/.htaccess), which probably was set up by WordPress. There may be customization in /.htaccess to prevent WP from interfering with the store (ignore URLs which are headed towards the store).

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...