.htaccess - 301 redirect with query strings -


i'm new programming , brand new site (although has helped out many times i'm trying learn stuff...so far!).

my question relates 301 redirects. i've been searching site many other pages through google , can't seem find solution works me (i'm guessing solution out there since seems common problem...but haven't yet been able find it).

so here is:

i have site where: http://homework-heroes.com/php/views/newassignment.php?[then query string] goes same page.

for sake of eliminating duplicate content seen google, want these redirect to: http://homework-heroes.com/php/views/newassignment.php?final

what htaccess code should insert accomplish this?

thanks in advance!

place following in /.htaccess file:

rewriterngine on rewriterule %{query_string} !^$ rewriterule %{query_string} !^final$ rewriterule ^(php/views/newassignment.php)$ /$1?final [r=302,nc,l] 

the above says if query string not blank and request being made /php/views/newassignment.php, redirect same page ?final new query string.

alternatively, if remove query string altogether, remove final,leave question mark in rule, , remove second condition.

if you're happy , want make redirect permanent, change 302 301.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -