regex - htaccess - How to cut some text from url -
regex - htaccess - How to cut some text from url -
i have simple question htaccess, can't solve it. part of links of website on google search has fragment of url , don't know how fragment appeared there? here examle:
in google seach is:
http://dobry-portal.pl/part1-/tranformers,main,film,0
real adres http://www.dobry-portal.pl/tranformers,main,film,0
sometimes adrress on google seach have more 1 part between slashes ex. http://dobry-portal.pl/part1-/part2-/part3-/tranformers,main,film,0
how can cutting of parts in htaccess redirect real adres http://www.dobry-portal.pl/tranformers,main,film,0
i've tried
rewriterule (.)/part1-/(.) $1/$2 [l]
but not work
thanks help, adam
this should remove "fake subdirectories" between slashes you:
rewriterule ^.*/([^/,]*,.*) $1 [l,r=301]
^.*/
greedily matches path lastly forwards slash ([^/,]*,.*)
captures grouping 1... [^/,]*
characters not slashes or commas, ,.*
comma , rest of string the $1
back-reference substitutes grouping 1 url [l,r=301]
lastly rule, permanent redirect i'm sure tweaks possible, should started.
regex apache .htaccess mod-rewrite
Comments
Post a Comment