There is a site in php, the problem is that it is encrypted, and I would like to remove the word “search” from the links, can it be done like that with the help of htaccess and that the site does not collapse?

Example http://site.ru/search/flats/ do http://site.ru/flats/

  • It is impossible, since you do not have access to the code that generates the links. .htaccess does not help here. - Visman
  • one
    @Visman will help, for this purpose mod_substitute is used - teran
  • @teran, can you tell me how to do this? - zoinx2012
  • @ zoinx2012 added the answer, try it, maybe it will. But the expansion of the Apache must be enabled first. At the very least, look for examples on mod_substitution - teran

1 answer 1

To make changes to the generated content, you will need to enable the mod_substitute extension. According to the documentation, change directives can be made both at the Directory level and in .htaccess .

If it is necessary to change the generation of only href links, then the directive should look something like this:

  AddOutputFilterByType SUBSTITUTE text/html Substitute "s|http://site.ru/search/|http://site.ru/|ni" 

in this case, a case-independent replacement of the substring without the use of regular expressions should be performed, which should replace all links beginning with http://site.ru/search/ to http://site.ru/ (more precisely, the beginning of links).

But it should be understood that in addition to the links in the html-content there may be other places of use of addresses, including java-scripts, various attributes, etc.

  • PS: in practice I have never done this, the answer is based on the documentation page. It does not pretend to complete correctness. - teran