Htaccess Querystring rewrite

前端 未结 1 1214
轮回少年
轮回少年 2021-01-25 14:27

I have URLs like /?test that I want to rewrite to /page.php?page=test

I tried like this but for some reason it doesn\'t work.

R         


        
1条回答
  •  既然无缘
    2021-01-25 14:53

    The query string can only be tested with the RewriteCond directive. The RewriteRule pattern is only tested against the URL path (in .htaccess files the URL path without the per-directory prefix).

    So try this:

    RewriteCond %{QUERY_STRING} ^[a-z0-9-+]{3,20}$ [NC]
    RewriteRule ^$ /page.php?page=%0 [QSA]
    

    0 讨论(0)
提交回复
热议问题