@alicia130
The logic order of the second attempt was correct (page redirect, general non-www redirect, rewrites) but the code could do with some improvements.
The code in the third attempt was much more robust, however it was simply missing
Code:
RewriteRule ^cart http://example.com/ [R=301,L]
or similar, as the very first rule.
Let's take a closer look at that single line of code. Is that very first rule supposed to be "moving" a store from the folder to root?
That code as you have it now would redirect example.com/cart/index.php?parameter=value to example.com/?parameter=value which would cause problems - because the index.php part of the new URL would be missing.
Does it need to preserve the path and/or parameter values in that redirect?
If it does not need to preserve the path and parameters, then changing http://example.com to be http://example.com/? would simply clear the parameter values instead.
If it does need to preserve the path and parameters, there's more detailed code for that in: http://www.zen-cart.com/forum/showth...=150620&page=2 here (which also fixes other issues at the same time too).
Once the user is requesting the correct URL, only then do you attempt to serve the content.
To be clear about the terminology:
Redirects (code with domain name and [R=301,L] in) tell the browser to make a new request for a new URL. The user sees the URL in the URL bar of their browser change.
Rewrites (code with just a server-internal filepath and [L] flag) connect a URL request with a non-default internal filepath to find and serve the page content at the currently requested URL.
Bookmarks