Zen Cart Logo
Forums / General Questions / Friendly URLs without add on module

Friendly URLs without add on module

Views: 768

Results 1 to 3 of 3
7 Jun 2013, 7:03 PM
#1
larryweiss avatar

larryweiss

New Zenner

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

Friendly URLs without add on module

My site has only two categories and six products. So there ought to be a simple way to create user friendly urls without the disadvantages of an add on module.

I would like to redirect the category page
</index.php?main_page=index&cPath=1>
to the category page
</cars.php>
And similar for the other category, </trucks.php>

Then would like to redirect the item page
</index.php?main_page=product_info&cPath=1&products_id=2>
to the product page
</ford-cars.php>
And similarly for the other products, gm-cars.php.... etc

I think it can be done by redirecting(301) oldpage to newpage in .htaccess
Then changing all the menu links to static links.
Then changing site-map.htm and site-map.xml accordingly.

Would this work?

*Alternatively or concurrently

I would like to insert a<link rel="canonical" href="http://www.mysite.com/cars-ford.php"/> into the head of the Ford page. It would get the "cars-ford" from an entry I would create in /custom/meta-tags.php

I have no good idea how to do this, but its probably fairly simple.

Would this work?

Has anyone already worked this issue out?

7 Jun 2013, 7:41 PM
#2
allthingsidleroy avatar

allthingsidleroy

New Zenner

Join Date:
May 2013
Posts:
38
Plugin Contributions:
0

Re: Friendly URLs without add on module

Since it is only a few products, categories, and pages, you should be able to pull this off with Apache's Mod Rewrite.

You can hand-write the rewrites yourself. They go in your .htaccess in the root of your website.

Here's an example I whipped up off the top of my head:

RewriteEngine on 

RewriteRule ^/?cars$ /index.php?main_page=index&cPath=1 [L]
RewriteRule ^/?ford-cars$ /index.php?main_page=product_info&cPath=1&products_id=2 [L]

If you absolutely must have the ".php" on there (which I don't recommend), change it to this:

^/?cars\.php$
^/?ford-cars\.php$

Keep in mind that your links on the website would still show the old "main_pageblahblahblah.php" stuff. But you can give out some fancy looking urls this way, and quick. If you wanted to change how the website generated its urls for links, you'd have to edit the code, unless there's some other way I don't know about.

8 Jun 2013, 4:11 AM
#3
larryweiss avatar

larryweiss

New Zenner

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

Re: Friendly URLs without add on module

Thank you allthingsidLeroy

Appreciate the help

Larry