URL Rewrite like this.....

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
15 Jahre weitere
Hi,
can I change url to this format - now is http://localhost/Category/26-mp3-players.aspx is possible use this format http://localhost/Category/mp3-players - without ID and .aspx

And same way for product http://localhost/Products/35-apple-ipod-touch-32gb-mp3mp4-player.aspx to http://localhost/apple-ipod-touch-32gb-mp3mp4-player - without Products/35 and .aspx - this way for all product and categories.

thanks

Radomir
15 Jahre weitere
Sure.

1) Modify SEOHelper class ("GetProductURL", "GetCategoryURL" methods).
2) Modify "urlrewritingnet" section in web.config file
3) Setup your IIS for proper request handling
15 Jahre weitere
Can you publish example how to do it?
15 Jahre weitere
1) Modify SEOHelper class ("GetProductURL", "GetCategoryURL" methods).

        /// <summary>
        /// Gets product URL
        /// </summary>
        /// <param name="ProductID">Product identifier</param>
        /// <returns>Product URL</returns>
        public static string GetProductURL(int ProductID)
        {
            Product product = ProductManager.GetByProductID(ProductID);
            if (product == null)
                throw new Exception(string.Format("Product couldn't be loaded. ID={0}", ProductID));
            string seName = MungeSEName(product.Name);
            string url = string.Format("{0}Products/{1}-{2}.aspx", CommonHelper.GetStoreHTTPLocation(false), ProductID, seName);
            return url;
        }


2) Modify "urlrewritingnet" section in web.config file
   
           <add name="ProductDetailsRewrite" virtualUrl="^~/Products/([0-9]*)-([\w-]*)\(?:\?(.*))?"
           rewriteUrlParameter="ExcludeFromClientQueryString"
           destinationUrl="~/Product.aspx?ProductID=$1&amp;$3"
           ignoreCase="true" />


3) Search over interner for proper request handling (.aspx removed) in IIS.
15 Jahre weitere
it's very useful!
13 Jahre weitere
a.m. wrote:
1) Modify SEOHelper class ("GetProductURL", "GetCategoryURL" methods).

        /// <summary>
        /// Gets product URL
        /// </summary>
        /// <param name="ProductID">Product identifier</param>
        /// <returns>Product URL</returns>
        public static string GetProductURL(int ProductID)
        {
            Product product = ProductManager.GetByProductID(ProductID);
            if (product == null)
                throw new Exception(string.Format("Product couldn't be loaded. ID={0}", ProductID));
            string seName = MungeSEName(product.Name);
            string url = string.Format("{0}Products/{1}-{2}.aspx", CommonHelper.GetStoreHTTPLocation(false), ProductID, seName);
            return url;
        }


2) Modify "urlrewritingnet" section in web.config file
   
           <add name="ProductDetailsRewrite" virtualUrl="^~/Products/([0-9]*)-([\w-]*)\(?:\?(.*))?"
           rewriteUrlParameter="ExcludeFromClientQueryString"
           destinationUrl="~/Product.aspx?ProductID=$1&amp;$3"
           ignoreCase="true" />


3) Search over interner for proper request handling (.aspx removed) in IIS.



Please, I need a to retrieve productId from the productdetails page in the catalog. How can I do this programmatically? Please help me out.
12 Jahre weitere
My urlrewrite is pulling from the root of my main folder instead of the root from the url.

Example:

Should be: http://tsworld.biz/product/

Once urlrewriter kicks in it shows:

http://tsworld.biz/tsworld/product/

The folder structure for my hosting is root/tsworld

NopCommerce is installed in tsworld and should never look at the full root.  It is one of many websites on this server.

Inside the tsworld folder there is not another tsworld folder.

What do I change in urlrewrite to make it not show tsworld anymore?
12 Jahre weitere
I am also have a problem with URL Rewrite. When I give a non English name to a product then it cannot show the title. Then the page looks like : http://localhost/nop1.9/products/101--.aspx . What is the resolve of this problem?
12 Jahre weitere
ratul_63 wrote:
I am also have a problem with URL Rewrite. When I give a non English name to a product then it cannot show the title. Then the page looks like : http://localhost/nop1.9/products/101--.aspx . What is the resolve of this problem?


I addressed this issue here https://www.nopcommerce.com/boards/t/6696/developer-roadmap-1-moving-to-mvc-your-thoughts.aspx?p=29

Hope this helps!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.