0

I am using OpenCart 1.5.4 that I have install in a /products subdirectory. I have a wordpress site installed in the root directory. I have skinned them the same so it looks like the same site.

I would like to rewrite all instances of Home links (especially the breadcrumbs) to go to my root directory (rather than the sub-directory (/products) where my OC install is at).

From some research I understand that the best way to do this is in the HTACCESS file. I am very unfamiliar with manipulating the htaccess file. The standard htaccess file has these rewrite rules:

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] 

How can I add a rule to change the Home link from:

www.myurl.com/products/index.php?route=common/home

to:

www.myurl.com/

Finally, in the current install this file is called .htaccess.txt. Do I have to delete this file from the server, remove the .txt , and upload the file named .htaccess to make it work?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Matt
  • 211
  • 4
  • 16

3 Answers3

0

To remove the index.php?route=common/home follow the guide here. As for the .htaccess code, you will need to upload that to your opencart install directory and remove the .txt from the name so that it becomes .htaccess

Community
  • 1
  • 1
Jay Gilford
  • 15,141
  • 5
  • 37
  • 56
0

You cannot use http://www.myurl.com/ URL for both Wordpress and OpenCart since they both use index.php file. There's a work around you can use to make things look better:

You need a .htaccess file at your website root folder and in that .htaccess file add following lines:

RewriteEngine On

RewriteRule ^cart.php?route=([a-zA-Z0-9_-]+)$ products/index.php?route=$1

This will make your OpenCart accessible from URL: http://www.myurl.com/cart.php?route=common/home instead of www.myurl.com/products/index.php?route=common/home

Aniruddh
  • 7,648
  • 1
  • 26
  • 43
0

You Setup is just like my setup, It's like this...

  • Custom HTML in root - hxxp://mysite.loc/
  • OpenCart in /store folder - hxxp://mysite.loc/store

I have a mod similar to what Jay Gilford mentioned in his answer.
So my OC link is

http://mysite.loc/store


instead of


http://mysite.loc/store/index.php?route=common/home

With this setup, you will still find from the breadcrumbs path of any store links, the Home link. Like Home > Category > Product

In my case, what I did was, I've renamed the Home text to Store text. and had removed the Home Link Menu from the OC Menu. It's pretty simple, but practical I think.

I then added added my Home link to the breadcrumb trail and to my OC Menu. So my breadcrumb trail is like so...

Home > Store> Category > Product

Home link was hardcoded to every .tpl pages that contains the breadcrumb. Like the catalog/view/theme/default/template/product/product.tpl. You can further mod this by placing the breadcrumb to the header.

In my case, I've hard-coded this to my
catalog/view/theme/default/template/product/product.tpl and other related .tpl files

<div class="breadcrumb">
  <a href="/">Home</span></a>&raquo;
  <?php foreach ($breadcrumbs as $breadcrumb) { ?>
  <?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>
  <?php } ?>
</div>

I renamed the original Home link by doing this;

 changed
 $_['text_home']   = 'Home';

 to

 $_['text_home']   = 'Store';//Or whatever you like

 from the file. catalog/language/english.php - in my case.

I know this was asked several months ago, Just posting this one for future readers

GaryP
  • 2,173
  • 1
  • 21
  • 28