Apache Redirection

I would like to redirect the url using RedirectMatch in Apache for example

/ test / single / ?? redirect to / test / two / ??

where represents any string that follows

The redirection that I use below performs a direct redirect, but does not match any line after ... RedirectMatch Permanent ^ / test / one? $ / Test / two /

thanks a lot

0
source share
2 answers
RewriteEngine ON RewriteBase / RewriteRule ^/test/one/(.+)$ /test/two/$1 

If this does not work, replace ^ / test / one with ^ test / one

make sure mod_rewrite is enabled

+2
source

You can use mod_rewrite for this:

 RewriteEngine On RewriteBase / RewriteRule ^/test/one/(.*) /test/two/$1 [L,R=301] 

The R flag redirects the page, not the internal rewriting of the URI. 301 is the HTTP status code for Permanently Relocated - if you prefer to use another, you can change it to one of them .

0
source

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


All Articles