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
edited by

Hello

This partial url:

learn-greek-online.com/ask-greek/442/

gives a 302 redirect to this full url:

learn-greek-online.com/ask-greek/442/lexicon-can-you-tell-what-the-abbreviation-apollod-stands-for

This is done from core Q2A.

I would like to make those redirects to be 301, instead of 302.

What file/code should I change please?

Q2A version: 1.8

2 Answers

0 votes
by
Same here:

learn-greek-online.com/ask-greek/302/
learn-greek-online.com/ask-greek/302/fere-mou-to

I am wondering, since the page has the correct canonical tag "learn-greek-online.com/ask-greek/302/fere-mou-to", why does google index both pages?
by
You have to make changes in your htaccess code.

For example,
I have a website with the following .htaccess file:

AddType application/x-httpd-php5 .php
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

##RewriteBase /~site/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
#php values
#php_value register_globals 0
<IfModule mod_dir.c>
    DirectoryIndex index.php index.htm index.html index.shtml index.cgi
</IfModule>         
<FilesMatch "^\.ht">
Order allow,deny
Deny from all
</FilesMatch>

You can simply change 302 to 301.

Hopefully, it will help you
by
But in your code you do not have a 302.  How can I change it to 301?
by
I mean made change where 301 is mentioned.
You must be having 302 there, you need to change that to 301.
by
This is my htaccess file.  There is no 302 to change.  


>>>>>>
Options -Indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /

# remove the www
RewriteCond %{HTTP_HOST} ^(www\.learn-greek-online\.com)?$
RewriteRule ^(.*)$ https://learn-greek-online.com/ask-greek/$1 [R=301,L]

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>
<<<<<<

I don't think what you propose is a viable solution.
0 votes
by

Hello @bobptz,

This can be done by adding this line of code:

header("HTTP/1.1 301 Moved Permanently");

here: qa-include/pages/question.php

This answer describes how to do it in Question2Answer 1.8.5:

I hope it is useful.
Have a nice day!

...