Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
I need help changing vanilla default route
![xm1](https://us.v-cdn.net/5018160/uploads/userpics/013/nND5MFQGF7WJC.jpg)
For some very important reasons that has to do with integration, I need to change the vanilla default discussion route from siteurl/discussion/123/post-slug
to something likesiteurl/custom/123/post-plug
I have tried changing the routes from the dashboard->Routes (DefaultController and DefaultForumRoot), but when I change them, it breaks the forum.
0
Comments
Do you want to change the defaultroute or the destination url.
two different things.
most likely you want to change the destination url.
http://vanillaforums.org/discussion/comment/162397/#Comment_162397
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
routes are not explicit in vanilla yet. There is an implicit pattern mapped to the controller.
dashboard -> Routes describes redirects rather then actual formally define reversible routes.
grep is your friend.
There is a
DiscussionUrl
function which can be predefined. It may not always be adhered to. However if you have a route and a 301 redirect this could be a reasonable solution.grep is your friend.
Defaultroute or destination, I just want to change
siteurl/discussion/123/post-slug
to
siteurl/custom/123/post-plug
I just want to change the url of discussions
I just want to change the url of discussions
The answer is already there, but no step by step how to. You have to change the route. That should be possible by using the RewriteRules of your server. Search the internet for RewriteRule and htaccess to get a basic understanding. Maybe someone who knows about that better than me can support you later on, but you really should have a minimal knowledge.
I know I can use htaccess to do something like:
RewriteRule ^custom/([0-9]+)/([a-zA-Z0-9_-]+)/?$ discussion/$1/$2
This infact works.
Adding this code in my htaccess file makes it possible for me to visit the discussion at forumurl/discussion/123/post-slug using forumurl/custom/123/post-slug.
Now the challenge is how do I replace the urls of all the discussions in the forum with my new url pattern, basically replacing the "discussion" in the urls to "custom".
I don't think I can achieve that with htaccess. can I?
Now I've been able to redirect all requests to forumurl/discussion/* to forumurl/custom/* using routes.
But I need to change urls of all discussions to forumurl/custom/*
can the
DiscussionUrl
function @x00 mentioned do that for me? and where is this function located?create a file
/conf/bootstrap.after.php
put
as this is not full proof you may want to also 301 redirect
/discussion
to/custom
generally this function is used more than not.grep is your friend.
Thanks @x00 I think I've achieved what I want.
Now there is a challenge. Everything works well on discussions with all of its comment in one page, If discussion comments is up to 2 pages, when I go to page 2 I get only the discussion title, the pagination and the editor. Non of the comments that are supposed to display in page 2 will show up. When I manually change the url in the browser to
discussion
it works.