Joomla VirtueMart not working with IIRF

Topics: Developer Forum, User Forum
Jul 20, 2009 at 9:49 PM
Edited Jul 20, 2009 at 9:51 PM

Hi, I'm working on a site using Joomla and have enabled Search-Engine Friendly URLs. While they work with IIRF in lieu of the usual Apache .htaccess file, they cripple the VirtueMart shopping cart module - if I disable SEF in Joomla's backend, VirtueMart works properly, but if I enable it, all of the links automatically generated by VirtueMart (e.g. for shopping cart, product categories, etc) result in "page cannot be found" errors.

I haven't come across any solutions on the VirtueMart forums, and, since VirtueMart *does* appear to work with other Apache-based SEF plugins for Joomla, I'm wondering if this might have something to do with IIRF? Are there any lines of code I can put in the ini file to resolve the problem with VirtueMart links? This is what I have right now:

 

#This is final version of IIRF ini for standard SEF in Joomla!

#Make the following 0 in to turn debugging and logging completely off
RewriteLogLevel 2
 
#Write the absolute path of your output log file here 
RewriteLog G:\IIRFLog\IIRfLogfile
 
MaxMatchCount 10
 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_URL} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$
RewriteRule ^/(?!index\.php)(.*)$   /index.php/$1  [U,L]

 

Coordinator
Jul 20, 2009 at 10:34 PM

I'm sorry you're having problems.  Your INI file is very interesting, but I don't know Joomla, I don't know what VirtueMart is, and I don't know what the links that it generates look like.  I don't know how to help you.

I do know IIRF.  I know how to build rules that rewrite URLs.  I can advise you if you tell me the kind of URL you would like to expose to the world , and the kind of URL you would like to rewrite to (the internal URL).  I can help with that.

If you tell me "my links don't work", the best I can do is comiserate.  If you tell me specifically the rewrite you expect, and the rewrite you are getting, I can help figure out how to make URL rewriting work for you.

Jul 21, 2009 at 12:14 AM

Thanks Cheesio. Here are further details:

Joomla is a CMS whose default links look like this: http://www.example.com/index.php?option=com_content&view=article&id=5&Itemid=4

With SEF enabled (and using the Rewrite rules I posted above), Joomla's links take on this format: http://www.example.com/sample-page.html

VirtueMart is a popular online store module for Joomla. Its default links look like this:

http://www.example.com/index.php?option=com_virtuemart&Itemid=26&vmcchk=1&Itemid=26 (VirtueMart landing page)
http://www.example.com/index.php?option=com_virtuemart&page=shop.browse&category_id=1&Itemid=26 (link to a Product category within VirtueMart)
http://www.example.com/index.php?page=shop.cart&option=com_virtuemart&Itemid=26 (link to a user's Shopping Cart)

Now, with Joomla's SEF enabled and my Rewrite rules, those links become:

http://www.example.com/e-store.html (this one works)
http://www.example.com/e-store.html?page=shop.browse&category_id=1 (does NOT work - gives "page cannot be found")
http://www.example.com/e-store.html?page=shop.cart (does NOT work - also gives "page cannot be found")

Based on the above, are you able to tell if the problem is with my Rewrite rules?

Coordinator
Jul 21, 2009 at 3:55 PM
Edited Jul 21, 2009 at 3:56 PM

Are you saying you want to rewrite this way?

external URL rewritten (internal) URL
/e-store.html /index.php?option=com_virtuemart&Itemid=26&vmcchk=1&Itemid=26
/e-store.html?page=shop.browse&category_id=1 /index.php?option=com_virtuemart&page=shop.browse&category_id=1&Itemid=26
/e-store.html?page=shop.cart /index.php?page=shop.cart&option=com_virtuemart&Itemid=26

If so, I don't see any rules in your ini file that get anywhere close to doing this. There's nothing that matches on e-store.html, nothing that matches shop.cart, nothing that rewrites to virtuemart.

The way it works is this: you define rules in the ini file that match the incoming (public, SEF) URLs, and then rewrite those URLs to the ugly, internal ones. I don't see anything in the ini file that does anything close to what you're saying you want.

at the very least, you should have something like this:

# Rule 1
# redirect empty URLs to e-store.html
RedirectRule   ^/?$     /e-store.html 

# Rule 2
# append the option=com_virtuemart&Itemid=26 to every index.php URL that lacks it
RewriteRule    ^/index.php(?!option=com_virtuemart)(.*)       /index.php?option=com_virtuemart&Itemid=26  [L,QSA]

# Rule 3
# rewrite e-store.html with no params, to the default page
RewriteRule    ^/e-store.html$      /index.php?option=com_virtuemart&Itemid=26&vmcchk=1   [L]

# Rule 4
# rewrite the browse page
RewriteRule  ^/e-store.html\?page=shop\.browse&category_id=1$  /index.php?page=shop.browse&category_id=1

# Rule 5
# rewrite URLS like e-store.html?page=shop.cart to index.php?page=shop.cart&option=com_virtuemart&Itemid=26
RewriteRule ^/e-store.html\?page=([a-z\.]+)$   /index.php?page=$1

The first one just takes care of empty URLs - you can redirect them to the e-store.html URL. You didn't ask for this, but you might want it. Rule 2 adds the querystring params for any incoming URL that lacks them. Rule 3 rewrites the bare e-store.html URL . Rule 4 and 5 do the shop.browse and shop.page URLs you mentioned. Actually Rule 5 does a wildcard, so that shop.page matches, but also any character sequence that includes only alpha characters and the dot.

This is just an example to get you started. The above is not the final answer. I suspect there are other pages that need to be rewritten, and aren't covered by the above. I suspect you may want to handle category_id when it is other than 1, but currently category_id=1 is hardcoded in the rules.   ItemId=26 is hardcoded, and that looks suspect.  And you probably want other rules to filter out "bad" URLs and send them to a 404 page.

You've also got to test the rules you design with your own URLs. I suggest you check out the testdriver tool for that purpose.

I'm going to offer some additional unsolicited feedback to you.  This is intended to be helpful, not critical, and I hope you take it in the right way.  Here goes:  Based on the questions you are asking me and the information you are providing to me, I think you need to learn quite a bit more about rewriting in general. For example, you suggest that you want to expose a URL like /e-store.html?page=shop.cart to the public, and then rewrite it to /index.php?option=com_virtuemart&Itemid=26&page=shop.cart. But why would you not simplify even further, and expose a cleaner public URL, like /e-store.html?cart to the public?

And before you deploy a store using this technology, you need to learn more about IIRF in particular. There's no way I would deploy an online store unless I had a clear understanding of the pieces that made it work. You asked me "why doesn't this INI file work?" But it was obvious to anyone who knows even a little about IIRF that the ini file you gave was not going to work.  Not even close.

I think you need to put more thought into this. Read up on IIRF, and on rewriting in general. My sense is that you are just hoping to get a straightforward answer, but I am not able to just give that answer to you.  I can tell you about IIRF but you need to apply it to your environment, or hire an expert who can.   I hope I've gotten you started.

Jul 21, 2009 at 4:20 PM

You're right, I only know a little bit about rewriting rules as they pertain to .htaccess files in Apache. The ini file I originally posted is based on something I found elsewhere (maybe on this forum, I'm not sure) - rewrite rules designed to "fool" Joomla (a CMS designed for Apache-based systems) into thinking it was using a normal .htaccess file. They work beautifully for all of Joomla's other URLs, which is why I don't want to mess with them. The only thing they don't work for are the VirtueMart URLs. The effect I was going for was nothing more than this:

http://www.joomlaplugins.net/virtuemart-sef-router.html?page=shop.browse&category_id=2 (where virtuemart-sef-router.html is whatever SEF name you give the main store page...the rest of the query strings could stay as they are, just as long as they work!)

The above link is a demo from someone who's written an SEF plugin for VirtueMart, one that unfortunately only works if you're using Apache with Joomla's default .htaccess file (and when I copy those default rules into my IIRF ini file, they don't work). I figured it was only a matter of tweaking the IIRF Rewrite rules to get them to recognize VirtueMart URLs along with normal Joomla URLs, but evidently, it's far more complicated.

And no, it wasn't my choice to use Joomla on an IIS server - it was the setup the client already had, so I was stuck with it :(

Coordinator
Jul 21, 2009 at 8:08 PM
Edited Jul 21, 2009 at 8:10 PM

Ahhhh!  ok.  Things are clearer now.   From what you said, the SEF plugin for VirtueMart - that is the thing that is rewriting URLs, or more accurately, routing URL requests within Joomla.  The IIRF rules you showed me that "work for Joomla" don't do anything special for virtuemart.  So the reason the solution I've started you on, with IIRF, is more involved than you were expecting, is that I did not know about this SEF router thing.  I was writing IIRF rules to replace or duplicate the logic that resides in the Virtuemart SEF router code.

With all of the pieces - IIS, IIRF, Joomla, Virtuemart, and the SEF router - in effect you have 2 layers of rewriting logic going on.  It should not be necessary to have two.  It seems to me that any work done by a SEF router for Virtuemart, could be done by a set of rules in .htaccess or IIRF.ini.   But maybe it is more easily configured in the SEF router.  I don't know.  Whether it is necessary is irrelevant - the fact is that there are two rewriting layers. 

Stepping back, the real problem you had, originally, is that the Virtuemart SEF router is not working with IIS+IIRF, right out of the box.  The initial IIRF rules you showed me are simple enough, and I'd guess that if they work with "plain joomla", they should not need to be changed.  You need to figure out why the SEF router for virtuemart is not working.  Is there a log for that?   

On the other hand, you may want to just re-engineer the rewriting logic in IIRF, and just scrap the SEF router for Virtuemart.  If you'd like to figure out rules for making SEF urls work within virtuemart, with IIS, and without using that virtuemart SEF router, I could help you.  Even without knowing anything else, I'm pretty sure it will be possible to do it using IIRF rules only.  But it would require some additional effort, and you'd have to understand and be able to articulate exactly how to do the rewriting in the general case, in order for me to help you.  

Normally you'd want URLs for an e-store to look like this;

external rewritten (internal)
/product/3763/Hypergizing_ray_gun index.php?option=com_virtuemart&product_id=3763
/category/24/Industrial_Coatings index.php?option=com_virtuemart&category_id=24&page=shop.browse
/cart index.php?option=com_virtuemart&page=shop.cart
/specials index.php?option=com_virtuemart&page=shop.specials

...etc.

Rules that do this kind of thing are not hard to build in IIRF, but you have to be really clear on what you want.

 

Jul 26, 2009 at 9:23 PM

Hi;

@TQ Designs, First u'll need SEF ServiceMap component for Joomla, then VirtueMart Integrator for SEF ServiceMap. Then after u turn on Core SEO of Joomla, everything should be OK! I'm using those atm and i have no problems with it. You can find SEF ServiceMap component and its VirtueMart Integrator from here: SEF ServiceMap

Hope this'll be useful for u.

Gratz, Khan (aka ThestraL)...

Jul 27, 2009 at 2:07 AM

ThestraL - that's a great plugin, but it doesn't seem to have solved my issue :( May I ask what kind of rewrite rules you're using in your IIRF ini file?

Jul 27, 2009 at 4:02 AM

Cheeso - I found the thread on this forum from where I got my original rewrite rules: http://iirf.codeplex.com/Thread/View.aspx?ThreadId=32771 (see the 2nd-last post by frmusr)

Assuming I'm completely out-of-luck getting SEF to work with VirtueMart, is there a rewrite rule I could add to my ini file which would exempt any URLs with virtuemart from being rewritten?

Coordinator
Jul 27, 2009 at 6:57 AM

Sure! you could do that.  you just have to have a RewriteRule that matches any virtuemart URLs, wioth a rewrite pattern of  -.  Check the doc!

 

Jul 28, 2009 at 2:29 PM

Hi again,

I have to say that I am actually newbie about those stuff. I just found here while i was searching smth about joomla =). And saw that u were seeking (as i understood) a solution using SEF with VM. So, I at the beginning i was searching the same, but there were no free extensions for that. When I found the sef servicemap and its plugin then everything went ok. Well, I thought u'd need a component for that, I really have no ide about IIRF thing =P, and I did nothing about the IIRF to make it work on my website (I simply installed SEF ServiceMap, then installed its VM integrator then went to activate SEO settings from the Global Joomla configuration, and thats all), but dunno if this SEF ServiceMap (or its source code) component would help u about it. I wish it'd have helped =}

Btw, sorry for my English.

- ThestraL