Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.3k views
in Q2A Core by
Hi! I've recently installed Q2A on a website subdomain (e.g: http://www.domain.com/q2a/) and I have some problems trying to set up question URLs.

Despite the fact that there are some customization options in admin settings, I'm looking for another simple combination that's not available to select. What I'm looking for is for an estructure for questions like the following one:

http://www.domain.com/q2a/title-question-here-2
instead of
http://www.domain.com/q2a/2/title-question-here

Is there anyone else looking for the same?
I don't know if it's posible to do so but a URL without the question id between slashes would be perfect for something that I'm looking for.

I checked the htaccess and files like qa-base.php and many many more where it seems that q2a is doing something with URL but I haven't found anything. Hope you can help!

Thanks in advance
by
You can of course make this work with custom modifications but do not think it is a good way as this would break some plugins or even core which reply on such a structure to get the postid.

3 Answers

0 votes
by
Hi another time ;) Does anyone know how to solve this problem or has been in the same situation as me?
thx a lot for your help
0 votes
by
Probably, such URLs will not be allowed. Because URL also changes when the question title is changed. At that time, the bookmarked link will be invalid. Incidentally, Q2A does not consider the title part when interpreting the URL.
+1 vote
by

I think this should be doable with two main steps, using htaccess and overriding the request function.

Step 1: create an override plugin that overrides the function qa_q_request (from qa-base.php). You'll want mostly the same function but for the last line put

return $title . '-' . (int) $questionid;

Step 2: update your htaccess to handle the new format of URLs. Above the last RewriteRule I think you'll want something like this:

RewriteRule ^([^/]+)-([0-9]+)$ index.php?qa-rewrite=$2/$1&%{QUERY_STRING} [L]

Not sure if that's exactly right but should be similar.

...