Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+6 votes
1.1k views
in Q2A Core by
edited by

Hello

If the user has a space in his username (like for example "John 123") there is problem with entering his user's site because of the space in the link. It links me to address domain.com/user/John 123 (and causes error 403) instead of domain.com/user/John+123. What is more, when I manually type domain.com/user/John+123 it says: Page not found! Which means the user profile site is completely inaccessible.

I think the issue may be generated by version 1.8.8, because I didn't have such a problem anytime before. Now it appeared and I don't know exactly when, but most probably a few days ago, after updating Q2A to latest version.

What is wrong and how can I fix that?

EDIT: I just confirmed that issue is generated only in v. 1.8.8. I set up test Q2A site using the same database, but in v. 1.8.6 and this problem doesn't exist there.

Q2A version: 1.8.8
by
I had this same issue with version 1.8.8. The only solution I found was to go back to version 1.8.7. Too bad this version still has some PHP errors
by
1. Can you share your web browser configuration files and version?

Please, also include anything that might be affecting it, for example, .htaccess files.

2. If you replace the "+" character with a "%20", does it work?

3. Do you know if your hosting provider is modifying the URLs somehow?

4. Do you use CloudFlare or a similar service that might be between the end user and your server?

5. Does this happen in Chrome and Firefox?

6. From which Q2A page is the link generated with a space? (e.g. is it from the /users page that you see a link with a space instead of a %20?) A link to your site would help as well
by
@pupi1985
1. This problem occurs on both Mozilla Firefox and Google Chrome. .htaccess file isn't modified as well, there are only standard rules from .htaccess-example and "AddType application/x-httpd-php81 .php" to have a php v.8.1.
2. Unfortunately it doesn't help.
3. I don't know anything about it.
4. No.
5. Yes.
6. The link with space is generated both from /users page and from questions page. I don't even know if the users with space in their username are still able to log in on my site.

I'll tell you more info (including address to my site) in PM.
by
Can you share with me the .htaccess file, just in case?

Also, is the issue fixed if you change this line:

    RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]

With this line:

    RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [B,L]

Or maybe better, this one:

    RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [BCTLS,L]

Finally, what version of Apache are you using exactly?
by
edited by
Ok, I replaced the line you mentioned and now it's working. The script still generates links with spaces included (is that ok?), but they now lead to proper profile pages instead of error 403.

Below there is my full .htaccess file after this last change, with only website address replaced by a phrase "(website-address)".

Options -Indexes
DirectoryIndex index.php
AddType application/x-httpd-php81 .php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ (website-address)/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [BCTLS,L]
</IfModule>
by
I had this same issue with version 1.8.8.
by
because of this my site getting error in google console, most of profile url changed with  + to blank unicode

1 Answer

+6 votes
by
selected by
 
Best answer

In your htaccess you need to add a B flag to the last line, like this:

RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [B,L]

It’s due to some changes with the urlencode function. For some reason this didn’t get updated in the htaccess-example on the bugfix branch, only the dev branch.

by
because of this my site getting error in google console, most of profile url changed with  + to blank unicode, so we downgrade my q2a cms to 1.8.6.
by
I'm getting same issue.

user page not found due to missing "+"
...