I'm having an issue that I'm having trouble working out regarding a site I'm currently working on. The root of the site is Joomla - with OpenCart installed in the /products directory (so, URLs are "
www.domain.com" [Joomla] and "
www.domain.com/products" [OpenCart]).
Everything works as I expected it to, except the Mod_Rewrite for SEF URLs. I had already posted some of this issue in another thread, but since I've continued trying to solve the problem, this thread seems more relevant.
Essentially, with mod_rewrite activated in both Joomla and OpenCart, I get the expected URLs on the Joomla side ("
www.domain.com/article" or "
www.domain.com/category/sub-category/article"), which is great. However, once I click on the "Products" menu item (which is just set up as an external URL set to "
www.domain.com/products"), things change. Initially, all looks fine - The OpenCart side has 2 main categories with each having a handful of sub-categories. Now, all of these categories and sub-categories have perfect SEF URLs ("
www.domain.com/products/category/sub-category"), but once I click on an individual
product, I get something like this:
"
www.domain.com/products/category/sub-ca ... duct_id=54"
In the other thread I posted in, I thought I had debunked a theory that the .htaccess file in the root directory (Joomla) was interfering with OpenCart's .htaccess file because I turned off Joomla's SEO Urls and mod_rewrite and I renamed the .htaccess so it wouldn't be used. When I did that, there was no change in OpenCart's URLs.
THEN, I copied my installation of OpenCart to a new directory (one that didn't have Joomla installed above it) and once I set all the config files for the new location, it worked perfectly - SEF URLs and all.
As soon as I install Joomla in the parent directory and turn on mod_rewrite, it goes back to my original problem. But the thing that I don't understand is why when I turn Joomla's mod_rewrite back off, OpenCart's URLs don't revert back to the correct SEF URLs - instead, they remain the same - as if I hadn't even turned Joomla's SEO settings OFF at all - which is quite frustrating. So, anyone who can tell me why turning Joomla's mod_rewrite ON seems to permanently affect OpenCart whether or not I turn it back OFF would be INCREDIBLY helpful.
So, I'm left to figure out how to resolve this. I could leave Joomla's mod_rewrite off and just use their SEO Urls (like, "
www.domain.com/index.php/article" - which I suppose is better than the default URL mess)
OR I need to figure out how to keep Joomla's .htaccess from interfering with OpenCart's .htaccess.
Now, I have to admit - I really don't know much about mod_rewrite. The conditions and rules in the .htaccess files are Greek to me - although I did manage to find a code snippet that supposedly blocks rules from affecting specified sub-directories:
Code: Select all
RewriteCond %{REQUEST_URI} !^/(products|products/.*)$
I just put my sub-directory name in the place that the example had put theirs - but this hasn't had any effect as far as I can tell (it certainly isn't fixing the URLs).
SOooooo... I'm going to post the 2 .htaccess files below and I hope that someone who can read them (and understand the rules and conditions and such) can tell me how to resolve this.
Joomla's .htaccess file (in the site's root directory):
Code: Select all
AuthType Basic
AuthName "Development Folder"
AuthUserFile "C:\xampp\security\htdocs\DEV\passwd"
require valid-user
##
# @version $Id: htaccess.txt 14401 2010-01-26 14:10:00Z louis $
# @package Joomla
# @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
# @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##
#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
#
# mod_rewrite in use
RewriteEngine On
## Excludes Opencart subdirectory so it can use it's own .htaccess file
RewriteCond %{REQUEST_URI} !^/(products|products/.*)$
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section
OpenCart's .htaccess file (in the sub-directory "products" of the site):
Code: Select all
# 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
RewriteBase /products/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
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
Any helpful insight is greatly appreciated - my deadline for launching this site was today - so I'm trying to get as much info as I can by Monday so I can present my boss with either a solution - or fallback to plans B or C (B = not using Joomla's mod_rewrite at all; C = Trying something like JooCart*)
If a mod thinks this post would be more appropriate in it's own thread, feel free to move it - it just seems like this would be useful info to someone else trying to integrate Joomla and OpenCart per this thread's subject.
*Anyone who has implemented JooCart: Can you please post some detailed description of what is required and how to go about installing it? The softPHP website isn't very clear. I'm mainly concerned with how to import the MySQL tables for Categories and Products.
Edit: I think I've fixed my issue - it seems that one of the 2 mods I have installed altered the "catalog/model/tool/seo_urls.php". Replacing it from a clean copy seems to have fixed the URLs. I'm still testing it, but unless I have any surprise developments, I think I can call this one "solved".
Just to clarify, one of the mods is a Free Shipping Banner and the other is a custom mod (I think) that replaces the default add to cart button with one that pulls from a new product field which is merely a link to a shopping cart website (1shoppingcart). Both of these mods were developed before I took over the website. If they both didn't make so many changes to core files, I'd try to vQmod them - because I've really wanted to try that out.