Jump to content

Need serious URL help - what I see doesn't match what I read here

Bill in Kansas City

Recommended Posts

CubeCart 6.4.2, Windows 2016. 

CC is creating URLs that look like this:




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

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.)


Edited by bsmither
Link to comment
Share on other sites

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.

Edited by Bill in Kansas City
Link to comment
Share on other sites

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>

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.

Edited by bsmither
Link to comment
Share on other sites

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" />
                    <action type="Rewrite" url="/index.php?seo_path={R:1}" appendQueryString="false" logRewrittenUrl="true" />

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

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

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

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,


Apparently I battled this same exact problem 3 years ago: 


Only now, my web.config doesn't seem to be read (maybe because it's in a parent directory?):

  <!--This is for Cubecart!!!-->
    <httpErrors errorMode="Detailed"/>
        <rule name="rule 1R" stopProcessing="true">
          <match url="^cubecart/(.*)\.html?$" />
          <action type="Rewrite" url="/cubecart/index.php?seo_path={R:1}" appendQueryString="true" />


Please let me know how to "hook this up" to my new cubecart installation.

Edited by stevebo
Link to comment
Share on other sites

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]


<rule name="home">
    <match url="^$" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="Rewrite" url="/index.php" />

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.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...