Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Q2A Core by
redirect For non-www to www

Via .htaccess

 vps server

 CYBERPANEL control panel

 I ask those with experience to advise me... Thank you in advance
Q2A version: Question2Answer: 1.8.8
Is there any good use of using www over non www url? Though it depends on users technically I don't find it useful.
All pages of my website appear in Google with www. Please let me know how this worked
Do you want to redirect arbitrary subdomains (e.g. something.example.org, other.example.org, etc.) or just the second-level domain (example.org)?
second-level domain




 As well as another site to convert from


1 Answer

+4 votes
selected by
Best answer

Try adding

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

as the first rewrite rule in your .htaccess (directly after RewriteEngine On).

Rewriting example.org to www.example.org and also rewriting www.example.org to example.org does not make any sense, as that would have the rewrite go in circles.

Please sir, I have a very slow problem when posting new questions by a registered user and also when editing them.
 Please help me solve the problem and I am willing to pay for the service to fix the problem
edited by
Please do not move the target. If this answer resolved your original question: consider accepting it. If it didn't resolve the original question: provide more information about the problem (preferably by editing the question). If you have a new question: post a new question.