掲示板

modifying blogs url

11年前 に Szymon Marciniewicz によって更新されました。

modifying blogs url

New Member 投稿: 18 参加年月日: 12/02/13 最新の投稿
Hi,

I'm trying to change blogs URL from something like:

http://localhost:8080/blog/-/blogs/two-days-later-?_33_redirect=localhost:8080%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

to have only blog/title-of-the-blog-post
something like that:

http://localhost:8080/blog/two-days-later

Thanks to some posts in the forum, like this one : http://www.liferay.com/community/forums/-/message_boards/message/13086381
I know how to change it to this format: http://localhost:8080/blog/-/blogs/two-days-later
but how can I get rid on the "/-/blogs" part?
11年前 に Srikanth Konjarla によって更新されました。

RE: modifying blogs url

Junior Member 投稿: 51 参加年月日: 08/10/25 最新の投稿
One of the ways you could accomplish this is by writing a url rewrite rule using urlrewriter which is bundled with the core.
For Example in urlrewriter.xml

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

I have not tested this for syntax.
11年前 に Szymon Marciniewicz によって更新されました。

RE: modifying blogs url

New Member 投稿: 18 参加年月日: 12/02/13 最新の投稿
Thanks, I've tried that solution and the redirection works.
However there are some issues with this solution. The thing is - when pointing with mouse cursor on the blog link from the blog portlet, at the bottom of the web browser generated url can be seen, which is still with "/-/blogs" part. I would prefer to remove that completely. And after setting permanent redirection I can't access blog webpage at all, because it's being redirected with this rule and I think it has to go through url mapper.

Anyway I was thinking about changing url link generation and then setting mod_rewrite redirection to change the link to open the blog page. But I don't really know how to achieve that.
11年前 に Srikanth Konjarla によって更新されました。

RE: modifying blogs url

Junior Member 投稿: 51 参加年月日: 08/10/25 最新の投稿
Try the same rule without 'type="permanent-redirect"'
11年前 に Szymon Marciniewicz によって更新されました。

RE: modifying blogs url

New Member 投稿: 18 参加年月日: 12/02/13 最新の投稿
but is there any way to modify the url generation instead of using permanent redirection?
11年前 に Srikanth Konjarla によって更新されました。

RE: modifying blogs url

Junior Member 投稿: 51 参加年月日: 08/10/25 最新の投稿
Removing 'type="permanent-redirect"' from the rule helps you with that.
11年前 に Szymon Marciniewicz によって更新されました。

RE: modifying blogs url

New Member 投稿: 18 参加年月日: 12/02/13 最新の投稿
Yes yes, I noticed that after removing 'type="permanent-redirect"' from the rule I can then use apache modrewrite and redirection will work correctly, thank you for that.

However I was hoping to change the way of generating links to blog pages. I mean by that generating the link without the '/-/blogs' part. So even when I point on the link at the bottom of the browser I'll see link without '/-/blogs'. I've noticed it's possible on a website mymove.com/blog but I don't know how they did that.
11年前 に Szymon Marciniewicz によって更新されました。

RE: modifying blogs url

New Member 投稿: 18 参加年月日: 12/02/13 最新の投稿
Hey,

Has anybody got any ideas how it's being generated? I tried to modify BlogsEntryLocalServiceImpl.java in the ext plugin, but it didn't work, I don't know whether that was a good approach or not. Now I'm looking into jsp files og blog in portal-web but still can't find it.

Basically the requirement is to generate the url as localhost:8080/blog/blog-title

Any hints are more than welcome.
Thanks!