Search code examples
apache.htaccessmod-rewriteurl-rewritingfriendly-url

.htaccess rewrite specific page with backslash parameters


Please helt - I need a rewriteRule for a specific page with backslash paramters like:

/page/parameter1/paramter2

Rewriterule to

/anotherpage/paramter1/paramter2

tried this but i did not work:

RewriteRule ^page/$ /anotherpage.php/$ [L]

Solution

  • Converting my comment to answer so that solution is easy to find for future visitors.

    You may use this rule:

    RewriteRule ^page/(.*)$ /anotherpage/$1 [L,NC]
    

    Note that we match any text after page/ into a capture group and use the back-reference of the capture group $1 in the target.