Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
1.9k views
in Q2A Core by
Hi
In my site I have a main domain contains a q2a and another q2a in a sub-domain
I want to redirect both domain and sub-domain
domain.com   >>>>  www.domain.com
www.sub.domain.com  >>>>  sub.domain.com

But the problem is when I open a question page in subdomain it give error that :
======
A Question2Answer database query failed when generating this page.
A full description of the failure is available in the web server's error log file
======

codes in htaccess in main folder :
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{HTTPS} ^on$
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.[^.]+\.[^.]+)$
RewriteRule ^ https://%1%{REQUEST_URI} [L]

RewriteCond %{HTTPS} !^on$
RewriteCond %{HTTP_HOST} ^www\.([^.]+\.[^.]+\.[^.]+)$
RewriteRule ^ http://%1%{REQUEST_URI} [L]

Codes in sub domain folder :

DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
</IfModule>

Any help ?
Q2A version: 1.6.2

1 Answer

0 votes
by

use following in subdomain .htaccess file

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