Jump to content

Removing Trailing Slash while running in sub-directory


kbadgley

Recommended Posts

I am trying to run CubeCart in a sub-directory however I would like for the sub-directory to not have the trailing slash unless referencing a product/category/etc.

The following is what I'm getting..

  • www.domain.com/cube-cart/

And this is what I want..

  • www.domain.com/cube-cart

In easier to say terms, I want to remove the trailing slash after the directory. (As Cubecart is not running the whole site, but only a portion of it.)

Link to comment
Share on other sites

Wow. That will be interesting to pull off. There are statements that rely on some constants having a trailing slash.

The first place I would start is with the .htaccess file and ini.inc.php.

In .htaccess, there is a RewriteBase directive. I think the web server can handle a value that has or has not a trailing slash, so we can probably ignore that. At the end of the file, there is a 404 directive that specifically calls for /subdir/index.php. This can be changed to whatever page you want the web server to deliver, if anything.

In ini.inc.php, this is where CubeCart is figuring out where it is. A couple of key values can be overwritten by specifying them in /includes/global.inc.php:

$glob['storeURL'] = "http://www.domain.com/subdir"; // No trailing slash - will be added later
$glob['rootRel'] = "/subdir/"; // Must have trailing slash or just a slash

By not having a trailing slash on rootRel, we invite all manner of mayhem that will need to be fixed as we find it. So maybe we won't mess with that, but rather find where we can test for a trailing slash and remove it.

One place where we can try that is in the SEO class file, rewriteUrls() function. We can add a test here and if the to-be-returned value has a trailing slash, strip it.

Can you give us an idea where trailing slash URLs are showing up in your pages?

Link to comment
Share on other sites

Trailing slash that I want removed is just the one that follows the subdirectory segment.

www.domain.com/cube-cart/
                                    this one ^

All the files that follow that that show after that are fine... Ideally all I want to be able to do is remove that trailing slash when the "homepage" of the cube-cart installation is loaded.

I added the snippet (and edited) as you put into the /includes/global.inc.php file... and that did not do anything. (With and without the trailing slash)
 

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.

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