Is it possible to rewrite url using ColdFusion?

前端 未结 3 1671
礼貌的吻别
礼貌的吻别 2021-01-03 08:59

I have got a requirement for generating user friendly urls.I am on IIS.

My dynamic URLs looks like,

www.testsite.com/blog/article.cfm?articleid=4432

3条回答
  •  清酒与你
    2021-01-03 09:29

    I don't recommend using a missing file handler (or CF's onMissingTemplate). Otherwise IIS will return a 404 status code and your page will not be indexed by search engines.

    What you need to do is identify a unique prefix pattern you want to use and create a web.config rewrite rule. Example: I sometimes use "/detail_"+id for product detail pages.

    You don't need to retain a physical "/blog" sub-directory if you don't want to. Add the following rewrite rule to the web.config file in the web root to accept anything after /blog/ in the URL and interpret it as /?blogtitle=[everythingAfterBlog]. (I've added an additional clause in case you want to continue to support /blog/article.cfm links.)

    
        
            
            
                
                
            
            
        
    
    

    I recommend using a "301 Redirect" to the new SEO-friendly URL. I also advise using dashes (-) between word fragments and ensure that the character case is consistent (ie, lowercase) or you could get penalized for "duplicate content".

提交回复
热议问题