Bill in Kansas City Posted December 28, 2020 Share Posted December 28, 2020 CubeCart 6.4.2, Windows 2016. CC is creating URLs that look like this: mysite.com/category and mysite.com/category/product I can't find anywhere that describes what my URL rewrite rules should be. What do I need to do to make those links work? I've got the rule for .HTML files, but I'm not getting URLs like that. I've got a really pissed off client. Thanks for any help. Link to comment Share on other sites More sharing options...
bsmither Posted December 28, 2020 Share Posted December 28, 2020 For reasons that escape me, CC HQ decided that 'naked' URLs is to be the default. In admin, Store Settings, Search Engines tab, there is a new setting: SEO URL Extension. Setting this to '.html' will then add back the .html to the URLs. You might notice that all the paths in the database table CubeCart_seo_urls have had .html added to all the paths. It's baffling to me. The update appended .html to the data in the database, then strips it off when processing the path from a query, then adds it back according to the admin setting. The update also modified the .htaccess file to use a slightly more permissive rewrite pattern to accommodate the potentially missing suffix. I think someone made the argument that having no suffix on the URL is better for "SEO". If your rewrite rules are somewhere other than the .htaccess file, they must solve the same as: RewriteRule ^(.*)?$ index.php?seo_path=$1 [L,QSA] Use everything as the path. Do not expect to see .html (As before, the web server needs to know of a rewrite base, that after the rewrite base, which could be simply /, what follows is the friendly path.) Link to comment Share on other sites More sharing options...
Bill in Kansas City Posted December 28, 2020 Author Share Posted December 28, 2020 The change completely breaks the website, because if I put that rule in, the link to EVERYTHING else - stylesheets, javascript, images - stops working. My regex-fu isn't great enough to create a rule that works around THAT, and the "add html" doesn't appear to work either (unless that's only for new products.) ...and as long as we're here, the category links have stopped working as well. Time for a different cart, I guess. This is wayyy too much trouble. Link to comment Share on other sites More sharing options...
bsmither Posted December 28, 2020 Share Posted December 28, 2020 Does your site use a web server that reads the .htaccess? Assuming it does, these two rules in .htaccess make sure that there is first a test to make sure the requested folder and file does not actually exist. So, requests for javascript files, images, and css files that really do exist will be found and delivered. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d The problem I think that has come about is truly missing images, etc. There is a 404 override in .htaccess that is supposed to deal with missing page resources: ## Override default 404 error document for missing page resources ## <FilesMatch "\.(gif|jpe?g|png|ico|css|js|svg)$"> ErrorDocument 404 "<html></html> </FilesMatch> But if the rewrite rule catches everything, then there is no difference between a 'friendly url' that could be anything, and a non-existant page resource. I hope CC HQ constructs a better rewrite rule to account for this. When you say the category links have stopped working, I must ask that you verify that in the database table CubeCart_seo_urls, the paths all have (except three specific paths) a .html extension. Then clear CubeCart's cache. Link to comment Share on other sites More sharing options...
Bill in Kansas City Posted December 28, 2020 Author Share Posted December 28, 2020 I'm on a Windows server, so it uses IIS' URLRewrite module. Adding in the two rewrite conditions fixed the issue. I went through the products and made sure that ".html" is present on all of them, and that is now the default setting. For those who might need it, the rule looks like this: <rule name="generic rewrite" enabled="true" stopProcessing="true"> <match url="^(.*?)$" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="/index.php?seo_path={R:1}" appendQueryString="false" logRewrittenUrl="true" /> </rule> So far as I can find, IIS doesn't have a 1:1 equivalent to FilesMatch, and certainly not a way to specify blank 404 content. Man, what a pain. Don't they have a QA department? Thanks for your time and help! Link to comment Share on other sites More sharing options...
bsmither Posted December 28, 2020 Share Posted December 28, 2020 A QA department? Who? Microsoft? Haha! I have seen references to CubeCart being coded on a Mac. I assume it is tested on a Linux box. I am fairly certain CubeCart is not tested on IIS (and probably not on anything other than Apache). A snarky quip follows, but is not meant to be disparaging: Quality, Time, Money -- pick any two. Link to comment Share on other sites More sharing options...
Dirty Butter Posted December 28, 2020 Share Posted December 28, 2020 While fiddling with the commits before this latest upgrade I sometimes ended up with .html.html.html type extensions. I found I could fix the mess by doing a phpMyAdmin query to replace .html.html with a blank. And I also used the Maintenance setting to remove all custom seo urls. I kept playing with it until I could create the sitemap that looked correct. Link to comment Share on other sites More sharing options...
stevebo Posted January 5, 2021 Share Posted January 5, 2021 On 12/28/2020 at 1:17 PM, Bill in Kansas City said: I'm on a Windows server, so it uses IIS' URLRewrite module. Hi Bill, I have the same problem but I cannot change my ISP's IIS server, much less its URLRewrite Module (whatever that is). Would you let me know how to get my Cubecart installation to read .htaccess? Do I need to create a web.config? Or something else? Many thanks for any help, Steve Apparently I battled this same exact problem 3 years ago: https://disqus.com/home/discussion/cubecartknowledgebase/iis_rewrite_rules_to_prevent_page_not_found_errors_powered_by_kayako_help_desk_software/?utm_source=reply&utm_medium=email&utm_content=read_more#comment-3643669502 Only now, my web.config doesn't seem to be read (maybe because it's in a parent directory?): <!--This is for Cubecart!!!--> <system.webServer> <httpErrors errorMode="Detailed"/> <rewrite> <rules> <rule name="rule 1R" stopProcessing="true"> <match url="^cubecart/(.*)\.html?$" /> <action type="Rewrite" url="/cubecart/index.php?seo_path={R:1}" appendQueryString="true" /> </rule> </rules> </rewrite> </system.webServer> Please let me know how to "hook this up" to my new cubecart installation. Link to comment Share on other sites More sharing options...
Bill in Kansas City Posted January 5, 2021 Author Share Posted January 5, 2021 HEY Stevebo - wanted to post, let you know I see your question. I'll answer in full when I'm not putting out a fire for a client. - Bill in KCMO Link to comment Share on other sites More sharing options...
stevebo Posted January 5, 2021 Share Posted January 5, 2021 I think I've fixed it: <match url="^cubecart/(.*)\.html?$" /> should actually be <match url="^cubecart/(.*\.html?)$" /> I'm not fully convinced of this, but it seems to work so far... Link to comment Share on other sites More sharing options...
Bill in Kansas City Posted January 5, 2021 Author Share Posted January 5, 2021 If it works, don't fix it, right? Some general info you might find useful: Windows servers don't use .htaccess. Instead, all meta data regarding your site's behavior (including URL rewrites/redirects) are contained in web.config (as you've already noted.) The syntax is similar: a rule written for .htaccess can be used in web.config by just plugging in the values in the right spots, e.g. RewriteRule ^$ /index.php [L,R=301] equals <rule name="home"> <match url="^$" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Rewrite" url="/index.php" /> </rule> Search up "regular expressions" for more details on how the matching syntax works. Writing web.config by hand isn't fun, per se, but as you've discovered, it can be done. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.