I need to correctly write the regular expression for the address www.site.ru/search/отделка%20коттеджа/

This is what I wrote:

 '/^search\/отделка%20коттеджа\/$/i' 

In instanCMS there is a custom_rewrite.php file custom_rewrite.php it answers as the name implies for redirects over regular expressions as an example:

 $rules[] = array( 'source' => '/^search\/отделка%20коттеджа\/$/i', 'target' => '/old/other/otdelka-kottedzha.html', 'action' => 'redirect-301' ); 

if not for %20 , then everything would work, but my page is not redirected. I do not know how to get around this problem. Tell me please.

  • one
    Most likely, CMS makes urlencode for the address and therefore processes not a space, but you need the expression / ^ search \ / cottage decoration \ / $ / i - ReinRaus
  • If you have guessed it, write and I will comment on the answer. - ReinRaus
  • unfortunately they didn’t guess, I tried it anyway - shaman888

1 answer 1

DECISION:

it turned out to be very simple, when I inserted this link into the Opera browser, I received a conversion of the form:

http: //site.loc/search/%D0%BE%D1%82%D0%B4%D0%B5%D0%BB%D0%BA%D0%B0%20%D0%BA%D0%BE%D1 % 82% D1% 82% D0% B5% D0% B4% D0% B6% D0% B0

applying to the link the regular expression mask received:

  $rules[] = array( 'source' => '/^search\/%D0%BE%D1%82%D0%B4%D0%B5%D0%BB%D0%BA%D0%B0%20%D0%BA%D0%BE%D1%82%D1%82%D0%B5%D0%B4%D0%B6%D0%B0$/i', 'target' => '/old/other/otdelka-kottedzha.html', 'action' => 'redirect-301' ); 

everything works, thank you all.

  • one
    It would be politically correct to do first the urlencode of the data that came in the request, and then process it with the expression: / ^ search \ / cottage finishing \ / $ / i In this case, the redirect will occur regardless of the case of the letters in the request. In your decision, the case of letters plays a role. - ReinRaus