Display page on different url via htaccess

Silverstripe Version: 4.7.3


Hello, I have a problem with one solution. I need to display a certain page at a different URL address
for example:

where i use code from get to download some records from db and this page is created in cms and link to this page is /test. And this page working.

but now i want to display this page on another URL which should look like this:

in htaccess ive made rule for this but after this redirect i get 404 not found

by redirect i mean display first page on second url
there is any way to achive this?

RewriteRule ^test-(\d{4})/(([\sąćęłńóśźżĄĆĘŁŃÓŚŹŻa-zA-Z0-9_-])*)(\/)? /test/?code=$1&code=$2&%{QUERY_STRING} [L]

Ok i found that this rule in htaccess was not met but i check with flag R=301 and this rule working can someone explain me why rules without R-301 only [L] not working with original htaccess ? i include full file

# Deny access to IIS configuration
<Files web.config>
    Require all denied

# Deny access to YAML configuration files which might include sensitive information
<Files ~ "\.ya?ml$">
    Require all denied

# Route errors to static pages automatically generated by SilverStripe
ErrorDocument 404 /assets/error-404.html
ErrorDocument 500 /assets/error-500.html
#ErrorDocument 503 /assets/error-503.html

<IfModule mod_rewrite.c>

    # Turn off index.php handling requests to the homepage fixes issue in apache >=2.4
    <IfModule mod_dir.c>
        DirectoryIndex disabled
        DirectorySlash On

    RewriteEngine On

	RewriteRule ^test-(\d{4})/(([\sąćęłńóśźżĄĆĘŁŃÓŚŹŻa-zA-Z0-9_-])*)(\/)? /test/?code=$1&code=$2&%{QUERY_STRING} [L]

    # Process through SilverStripe if no file with the requested name exists.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule .* index.php

    # Enable HTTP Basic authentication workaround for PHP running in CGI mode
    #RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Deny access to potentially sensitive files and folders
    RewriteRule ^vendor(/|$) - [F,L,NC]
    RewriteRule ^\.env - [F,L,NC]
    RewriteRule silverstripe-cache(/|$) - [F,L,NC]
    RewriteRule composer\.(json|lock) - [F,L,NC]
    RewriteRule (error|silverstripe|debug)\.log - [F,L,NC]


I think thats becouse new SS must be mapped to Index.php and dont have url in params as old framework. But how can i achive my goal?
Please help :slight_smile:

I found one workaround for this solution if anybody need the same thing, it is example:

in /public/index.php we need to add if rule

if(preg_match('/test-(\d{4})/',$request->getURL())) {

So we need to getURL from request and change it to base url the same as we defined in CMS :slight_smile: