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

Hi guys,
I am using pretty URL's.
My website experience some strange behavior.
I am using force rewrite to www. and when you look at the URL of any question it appears like that
1. www.mywebsite.com/999/question-title  999 is the question number.

For some reason if you remove the www. then the url gets rewriten like that:
2. www.mywebsite.com/index.php?qa-rewrite=999/question-title or
3. www.mywebsite.com/index.php?qa-rewrite=999/question-title&show=999#q999 <= I could not reproduce at what conditions i've got this URL...

I am using sitemap plugin.
In google webmaster I found 25% of my website with error 404 because google have try to index the #2 URL's
What can I do so google do not try to index this URL's or send him correct data?
In XML Sitemap I have excluded all except the question pages.

Here is my current .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]
#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]
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.mywebsite\.com [NC]
RewriteRule (.*) http://www.mywebsite.com/$1 [R=301,L]
</IfModule>

Q2A version: 1.7.2 and Snow theme
by
The problem seems to be at this line:
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
Is there anyway I can safely remove this part "index.php?qa-rewrite=" ?

1 Answer

0 votes
by

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

I use this code on my site and it works. smiley

asked Oct 7, 2023 in Q2A Core by
closed Oct 7, 2023 by
Url with qa-rewrite is still there
...