Htaccess if the url contains the redirect line to the page without changing the url

I have a url like example.com/product-name.html.

I want to redirect any URLs containing the string htmlto search.php, but I want to keep the original URL that was entered, so if it example.com/product-name.htmlwas redirected to search.php, it should show example.com/product-name.htmlin the browser.

I use:

RewriteCond %{REQUEST_URI} html
RewriteRule .* search.php

Redirecting, but not saving, the original URL in the browser.

How can i do this?

+4
source share
2 answers

Try:

RewriteEngine on
RewriteRule html search.php [NC,L]

, .htaccess( ) config.
. .

0

RewriteRule mod_proxy

RewriteRule "/(.*)\.html$" "/search.php" [P]

mod_proxy . mod_proxy .

0

Source: https://habr.com/ru/post/1687513/


All Articles