Forums / General Questions / Shorter version of the URL

Shorter version of the URL

Views: 1,294

Results 1 to 16 of 16
18 Aug 2019, 4:09 PM
#1
caroleas avatar

caroleas

Totally Zenned

Join Date:
Feb 2009
Posts:
896
Plugin Contributions:
0

Shorter version of the URL

This might be a long shot, but I am giving it a try.

I am in the process of writing a book and would like to refer to some of my products in the store. Since the book is meant to be printed (yes, on paper), links are really kind of... complicated to include. Is there a way to provide a shorter link to some of the products in my Zencart store without having to use other services like Bitly or such?

I am assuming not, but I am taking a chance.

18 Aug 2019, 4:24 PM
#2
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Shorter version of the URL

Not sure if this is what you want but for print media I include something like this in my .htaccess file

Redirect 301 /tshirt1 https://mywebsite.com/clothes/tshirts/tshirt1

This redirects https://mywebsite.com/clothes/tshirts/tshirt1 to https://mywebsite.com/tshirt1

This shortens it somewhat although I'm not looking to shorten the domain name. I use a URI rewriter but I suspect it will work with ZC native URL's.

Simon

18 Aug 2019, 4:33 PM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Shorter version of the URL

If you use an htaccess file at the root of your store, you could provide a link as short as the domain name of your store, a slash, and a single character. Then in your htaccess you would have to forward that to your preferred product/location.

Otherwise, if you still find the dynamic uris "too long" for a location: 'index.php?main_page=product_info&products_id=x' then you may want to consider a uri rewriter. There are two recommended ones: Ceon URI Mappings and Ultimate SEO URIs. With Ceon you could use whatever you want in print and still have a normal preferred address. With USU the address can be shortened down to the product and/or category id's for the most part: '/-c-x/-p-y' and not include any text about the item/product.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

18 Aug 2019, 4:34 PM
#4
caroleas avatar

caroleas

Totally Zenned

Join Date:
Feb 2009
Posts:
896
Plugin Contributions:
0

Re: Shorter version of the URL

Oh that is interesting. It might be enough for me. I don't plan on shortening my domain either. I have an associated blog where I can use PrettyLinks, but i would be stuck having to include /blog/ in the URL, which is kind of misleading. But this might be just what i need.
Thanks.

22 Sep 2019, 2:30 PM
#5
caroleas avatar

caroleas

Totally Zenned

Join Date:
Feb 2009
Posts:
896
Plugin Contributions:
0

Re: Shorter version of the URL

Now that I am at that point in the book writing, I have a simplistic question: where is the .htaccess file? Or is it possible there isn't any yet?

22 Sep 2019, 5:03 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Shorter version of the URL

CaroleAs:

Now that I am at that point in the book writing, I have a simplistic question: where is the .htaccess file? Or is it possible there isn't any yet?
The .htaccess needed to support this typically would need to be added to the root of the store/domain as ZC does not need one it does not exist as part of the installation.

It will need to be added.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

22 Sep 2019, 5:12 PM
#7
caroleas avatar

caroleas

Totally Zenned

Join Date:
Feb 2009
Posts:
896
Plugin Contributions:
0

Re: Shorter version of the URL

Thank you!

22 Sep 2019, 6:49 PM
#8
caroleas avatar

caroleas

Totally Zenned

Join Date:
Feb 2009
Posts:
896
Plugin Contributions:
0

Re: Shorter version of the URL

OK I am not getting the result I want so I am obviously doing something wrong.

My domain is creationcassel.com, and my store is on creationcassel.com/store

I wrote:
Redirect 301 /align https://creationcassel.com/store/index.php?main_page=product_info&cPath=7_10&products_id=327

Will that create a link for creationcassel.com/align or creationcassel.com/store/align ?

And where to put the .htaccess file, would it be directly in the folder: creationcassel.com/store ? or somewhere else?

23 Sep 2019, 12:28 AM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Shorter version of the URL

How about clearly stating the wanted use of this rewrite concept so that hopefully a one time solution is provided.

The placement of the file and the contents of it will be different based on what is desired/needed and the result sought.

Also, when saying that not getting the result that you want, what result are you getting?

Lastly, is that one liner the only thing in the .htaccess file? If so, that is part of the problem...

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Sep 2019, 12:52 AM
#10
caroleas avatar

caroleas

Totally Zenned

Join Date:
Feb 2009
Posts:
896
Plugin Contributions:
0

Re: Shorter version of the URL

You are correct. I was probably somewhat unclear.

I am writing a book that will be printed (yes, on paper) so any link to a product in my store could not be clickable AND if i put the whole link it just looks "messy" and hard for someone to retype. So, I would like to have a shorter link that they could type with much less risk of typo.

So, for example, instead of this link:
https://creationcassel.com/store/index.php?main_page=product_info&cPath=7_10&products_id=327

I would like to be able to put something shorter, like:
https://creationcassel.com/align
and the viewer would be redirected to the full URL above.

One suggetion was to include that code (that i mentioned above) in the .htaccess file, but since I don't have one, I have to create one.

So there are the issue:

  • i probably created the .htaccess file wrong
  • i probably put it in the wrong place

Right now, if I type https://creationcassel.com/align (or even https://creationcassel.com/store/align), i get a 404, so that is my hint that i am doing something(s) wrong.

23 Sep 2019, 12:05 PM
#11
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Shorter version of the URL

Not an expert but I believe that you need to enable the RewriteEngine in the mod_rewrite module before adding the Redirect 301 line.

I'm assuming you are using Apache web server and that the Apache module 'mod_rewrite' is already enabled. As an example, in my htaccess I have

Options +SymLinksIfOwnerMatch
RewriteEngine on

Redirect 301 .....

I rarely use subdirectorys like '/store/ for my sites so I can't be sure as to the correct location for this htaccess, or whether it will rewrite as

creationcassel.com/align or creationcassel.com/store/align

I take more of a trial and error approach if I'm unsure.

Simon

23 Sep 2019, 12:38 PM
#12
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Shorter version of the URL

And recommend that if taking a trial/error approach to first use a non-permanent designation such as a 302 until sure that it works as intended. Especially with various cache capability between the site and the customer. Once the rewrite works, then go ahead and make it a 301.

I agree with simon1066's suggestion of at least enabling the RewriteEngine. The line above it may not be supported by the host, but is intended to provide a little bit of navigation protection.

To address the requested rewrite, the .htaccess file would need to be at or above the directory to which the domain name is located. By above I mean that the file path would be "shorter". This way when the domain is asked to find /align, that it will start at the domain name. If it were placed in the store directory, then it wouldn't be found if first the domain name were sought/used.

There may be some modifications necessary as can be identified by your host to ensure that the correct format is used for the environment in use.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Sep 2019, 12:46 PM
#13
simon1066 avatar

simon1066

Totally Zenned

Join Date:
Feb 2009
Location:
UK
Posts:
1,326
Plugin Contributions:
0

Re: Shorter version of the URL

mc12345678:

And recommend that if taking a trial/error approach to first use a non-permanent designation such as a 302 until sure that it works as intended. Especially with various cache capability between the site and the customer. Once the rewrite works, then go ahead and make it a 301.

I would recommend that a trial and error approach takes place on a test environment such as a local development server e.g. WAMPServer, XAAMP.

Simon

23 Sep 2019, 12:51 PM
#14
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Shorter version of the URL

simon1066:

I would recommend that a trial and error approach takes place on a test environment such as a local development server e.g. WAMPServer, XAAMP.

The recommendation of using a 302 instead of a 301 still applies regardless of the environment. For example if a short cut were put into the browser to use /align and then a 301 is issued, it is expected that the shortcut would get updated to the new location... and actually may want to consider always using a 302 or similar non-permanent redirect for that very reason. Ie. Published link is /align, it may point to location x for now, but later to location y. If a 301 is issued and that link updated say at a browser, then almost need to redirect the old location to the new location as well... not at all desirable to work that way. But with a 302 (or similar non-permanent redirect), the link is expected to remain as originally provided and will always be available for wherever it is modified to end up at.

ZC Installation/Maintenance Support <- Site
Contribution for contributions welcome...

23 Sep 2019, 4:44 PM
#15
mprough avatar

mprough

Totally Zenned

Join Date:
Nov 2007
Location:
Woodbine, Georgia, United States
Posts:
4,302
Plugin Contributions:
39

Re: Shorter version of the URL

Okay in your public_html/.htaccess try this at the very top of the file

RewriteEngine On 
Redirect 301 /align https://creationcassel.com/store/index.php?main_page=product_info&cPath=7_10&products_id=327

Yes, there will be some trial and error due to different server configurations and such. I will warn you that IF you have pages in the public_html that are similar to "align" it can cause a loop.

~Melanie

11 Oct 2019, 7:02 PM
#16
caroleas avatar

caroleas

Totally Zenned

Join Date:
Feb 2009
Posts:
896
Plugin Contributions:
0

Re: Shorter version of the URL

Thank you all. Out of "curiosity", I contacted my hosting company asking if they did have any module or service to create such redirect and although they don't, there is a place in the cpanel where redirects can be created on any domain of mine, so i won't even have to use the /store/ in the url.

So that is solved, and I am one step closer to have my book finished!