Page 1 of 1
Products - remove the id/category from the product URL slug
Posted: Thu Feb 24, 2011 12:37 am
by radiosilence
I've got version 2.10.3 installed. When I create a product, I'm getting a URL slug like this:
Code: Select all
http://www.domain.com/products/1/34/test-product-1
Is there a way to remove the "1/34" (what I assume to be the product ID and Category ID) from the URL and have it look like
Code: Select all
http://www.domain.com/products/test-product-1
Thanks in advance!
Re: Products - remove the id/category from the product URL s
Posted: Thu Feb 24, 2011 12:48 am
by calguy1000
At Present. No. The product ID, and the Page ID have to be somewhere on the URL.
There is a method that I can implement to remove them, however I have not had the time to do that of late. It will probably be a few more months before I can get to it, unless somebody wants to sponsor the modification.
Re: Products - remove the id/category from the product URL s
Posted: Thu Feb 24, 2011 3:53 am
by radiosilence
Might be interested in that. Let me know what I'd need to do to pursue that option.
Re: Products - remove the id/category from the product URL s
Posted: Fri Mar 09, 2012 9:29 pm
by proboscidian
Has there been any update on this?
Re: Products - remove the id/category from the product URL s
Posted: Wed Mar 14, 2012 7:01 pm
by peterbisset
Is it still not possible to do this?
Re: Products - remove the id/category from the product URL s
Posted: Thu Mar 15, 2012 7:31 am
by Peciura
General practice is to include both product ID and product alias to url. Lets say we have a product ID 123456.
Urls might look like
Code: Select all
www.hostname.com/p123456_product_alias
www.hostname.com/123456/product_alias
www.hostname.com/product_alias_123456
So if it is good enough for you you can create your own links
And add couple of lines to ".htaccess"
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^p([\d]+)_ index.php?mact=Products,cntnt01,details,0&cntnt01productid=$1 [QSA]
</IfModule>
Re: Products - remove the id/category from the product URL s
Posted: Fri Mar 16, 2012 2:35 pm
by peterbisset
Thank you for your reply. So if I wanted to change my product urls to "
http://www.domain.com/name-of-product/ for instance how would I modify my .htaccess file below?
Code: Select all
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
# Attempt to override some php settings, these settings may be helpful on some hosts if your
# default configuration does not meet CMS's minimum requirements, and your host
# has given your account appropriate permissions
#php_value upload_max_filesize "10M"
#php_value session_save_path "tmp/cache"
#php_flag magic_quotes_gpc Off
#php_flag register_globals Off
#php_flag session.use_trans_sid Off
# (this is important, so uncomment if your host permit)
#Options -Indexes
#ServerSignature Off
#Options +FollowSymLinks
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
# To prevend E_STRICT problems with PHP 5.3+ you can uncomment the following lines
# Note: These settings should only be enabled for production sites!
#php_flag display_startup_errors 0
#php_flag display_errors 0
#php_flag html_errors 0
#php_value docref_root 0
#php_value docref_ext 0
<IfModule mod_rewrite.c>
RewriteEngine on
#
#Sub-dir e.g: /cmsms
RewriteBase /
# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
# but ignore POST requests.
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
<IfModule mod_header.c>
# Disable ETags
Header unset ETag
FileEtag None
</IfModule>
<IfModule mod_deflate.c>
# Compress css, plaintext, xml, gif, and images in transport.
AddOutputFilterByType DEFLATE text/css text/plain text/xml image/gif image/jpeg image/png
</IfModule>
<IfModule mod_expires.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
# Set expires tags on various files... so that the browser wont attempt to reload them.
ExpiresActive On
ExpiresDefault "access plus 1 year"
<IfModule mod_header.c>
# Setting cache control to public allowes proxy servers to cache the items too.
Header set Cache-Control "public"
</IfModule>
</FilesMatch>
</IfModule>
Re: Products - remove the id/category from the product URL s
Posted: Mon Mar 19, 2012 9:57 pm
by Peciura
You can use product alias, not product name.
Your rewrite rules could look similar to these
Code: Select all
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_METHOD} !POST$
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]
#display valid content pages: "shipping" or "about-us"
RewriteCond %{REQUEST_URI} ^/(shipping|about-us)(\?.+)*
RewriteRule ^(.+)$ /index.php?page=$1 [QSA,L]
#anything else is supposed to be product alias
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index\.php
RewriteRule ^(.+)/$ index.php?mact=Products,cntnt01,details,0&cntnt01alias=$1 [QSA,L]
Re: Products - remove the id/category from the product URL s
Posted: Tue Mar 20, 2012 6:53 pm
by peterbisset
Thank you that works perfectly for generating the urls that I want. The only problem is that my {products} tag does not recognise any of the products now, even though they can be accessed by typing the url directly into the browser. Can you think of a reason why?
Re: Products - remove the id/category from the product URL s
Posted: Mon Apr 09, 2012 9:37 pm
by Peciura
...The only problem is that my {products} tag does not recognise any of the products...
Can you post link and explain in detail.