Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Aaron Paxson
Rewriting URL building in code??
July 3, 2011 7:36 AM
Answer

Aaron Paxson

Rank: Regular Member

Posts: 103

Join Date: July 27, 2010

Recent Posts

Is it so wrong of me to build a hook to re-write the generated URL's for the blog posts? I don't understand the Friendly URL mapping completely, but for me, it's only one way. When I look at a generated link, I still have all that junk in there:

http://www.myteneo.net/blog/-/blogs/the-asa-version-of-pix-alias-command?_33_redirect=http%3A%2F%2Fwww.myteneo.net%2Fblog%3Fp_p_id%3D33%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-1%26p_p_col_count%3D1

So, now, I'm building a hook to re-write all the code to actually generate the friendly URL of the actual link.

http://www.myteneo.net/blog/-/blogs/the-title-of-post

Which the Friendly URL mapper takes care of, and sends me to the right place.

Am I missing something or is this common practice. Thanks!
Raja Nagendra Kumar
RE: Rewriting URL building in code??
July 3, 2011 7:54 AM
Answer

Raja Nagendra Kumar

Rank: Expert

Posts: 484

Join Date: March 1, 2006

Recent Posts

Hi,

You could do the same rewrite by enabling the URLRewrite filter from turkey which is shipped in Liferay. Check
liferay\tomcat-6.0.26\webapps\ROOT\WEB-INF directory urlrewrite.xml and web.xml to enable this filter.

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
Aaron Paxson
RE: Rewriting URL building in code??
July 3, 2011 8:48 AM
Answer

Aaron Paxson

Rank: Regular Member

Posts: 103

Join Date: July 27, 2010

Recent Posts

Thank you, Raja. This was perfect!! *EXACTLY* what I needed:

urlrewrite.xml:

1      
2          <rule>
3                <from>(.*)/-/blogs/(.*)_33_(.*)</from>
4                <to type="permanent-redirect">$1/-/blogs/$2</to>
5          </rule>


web.xml:

 1
 2        <filter>
 3                <filter-name>URL Rewrite Filter</filter-name>
 4                <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
 5                <init-param>
 6                        <param-name>logLevel</param-name>
 7                        <param-value>ERROR</param-value>
 8                </init-param>
 9                <init-param>
10                        <param-name>statusEnabled</param-name>
11                        <param-value>true</param-value>
12                </init-param>
13        </filter>