EXCELLENT. Well done - I've finally found someone with a ZenCart website working and functioning as designed. :-)
So, to answer your question, you will need to create an .htaccess file and place it in the 'root' folder of your store (this is the same place that you'll find the favicon, robots.txt, ipn_man_handler.php and several other files).
In addition to the two lines already given, since this is a new .htaccess file you will probably need to add the following two lines at the start of the file
Options +FollowSymLinks
RewriteEngine on
The +FollowSymlinks probably isn't required - but most of the code examples I've just looked at seems to have it.
After you have confirmed that the two example redirects work (by typing the one to be redirected into your web browser) you *may* need to add additional rules for possible variants - This is especially true if your categories are nested - For example if that category '17' is a subcategory of category '1' you will find that both
index.php?main_page=index&cPath=17
and
index.php?main_page=index&cPath=1_17 both load the same page and depending on how the site is navigated either or both can be generated by Zencart - As such, you will need a redirect for both.
Although it is also possible to replace the 'simple redirect' with a 'RedirectMatch' which will enable the use of REGEX like expressions to cater for both variants with a single rule it isn't something I'd recommend at this stage, because it can be too easy to create a REGEX (Regular Expression) that will match things you don't want matched.
Please note, that I'm no expert in the syntax of any of the .htaccess rules. I tend to only use them to allow/deny access (coincidental name or what?) ;-)
In the times I need to know how to write a rule, I use Google to find a generator that crates them for me, then I just do a copy/paste. I even did this to provide you with the two examples already given :)
Anyway, I'm ranting again... start simple... extend as/when needed.
Tip: If you mess up the .htaccess rules (especially syntax errors) you *will* crash your site (typically a 'Server 500 error'). This is nothing to panic about - simply delete the file (or added rules) and redo.
There is no need to restart the server or clear any caches for changes to the .htaccess file to come into effect - The file is re-read with each and every page request - so its a matter of "stuff ups and fixes while you watch" so it is very easy to test/check that all is working as expected.
Cheers
RodG



Reply With Quote
