.htaccess - Duplicate URLs and solution in htaccess -
after years discovered bug in duplication urls try fix (author gone) despite htaccess rule thought should force it.
issue: have same content under 2 urls, ex:
http://www.wrock.pl/news-23069/depeche_mode_party_w_klubie_liverpool_/
www.wrock.pl/index.php?s=news&d=23069&nazwa=depeche_mode_party_w_klubie_liverpool_
or shorter www.wrock.pl/index.php?s=news&d=23069
another example menu pages:
www.wrock.pl/index.php?s=koncerty
i thought "index.php" version should hidden or redirected friendly url version, meanwhile both show 200/ok index.php gets redirected ok: www.wrock.pl/index.php
aim: able show friendly url version (redirect index.php version). google stopped indexing them may issue (one of many reasons).
here htaccess responsible presented examples:
rewriteengine on rewritecond %{http_host} ^wrock.pl(.*) [nc] rewriterule ^(.*)$ http://www.wrock.pl/$1 [r=301,l] # redirect index.php / rewritecond %{the_request} ^[a-z]{3,9}\ /([^/]+/)*index\.php\ http/ rewriterule ^(([^/]+/)*)index\.php$ http://www.wrock.pl/$1 [r=301,l] #news rewriterule ^news-([0-9]+)/([^-]+)/$ index.php?s=news&d=$1&nazwa=$2 [l,nc] rewriterule ^news/([0-9]+)/$ index.php?s=news&strona=$1 [l,nc] #koncerty rewriterule ^koncerty/$ index.php?s=koncerty [l,nc]
i dont know if current redirections should changes or should enter like:
#rewriterule ^index.php?s=news&d=([0-9]+)&nazwa=([^-]+)$ http://www.wrock.pl/news-$1/$2/ [l,nc]
which doesn't work of course.
thank suggestions.
above #news
items, need add these rules:
rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\?s=news&d=([0-9]+)&nazwa=([^-&\ ]+)($|\ ) rewriterule ^ /news-%1/%2/ [l,r=301] rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\?s=news&strona=([0-9]+)($|\ ) rewriterule ^ /news/%1/ [l,r=301] rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\?s=koncerty rewriterule ^ /koncerty/ [l,r=301]
and in order handle "shorter www.wrock.pl/index.php?s=news&d=23069
":
rewritecond %{the_request} ^[a-z]{3,9}\ /index\.php\?s=news&d=([0-9]+)($|\ ) rewriterule ^ /news-%1/ [l,r=301] rewriterule ^news-([0-9]+)/$ index.php?s=news&d=$1 [l]
Comments
Post a Comment