Query string rewriting using .htaccess

后端 未结 2 891
-上瘾入骨i
-上瘾入骨i 2021-01-23 16:07

i am trying to rewrite a URL for SEO purpose.

The old URL is:

http://www.domain.net/index.php?p=beer

The new URL should be:

<         


        
2条回答
  •  醉酒成梦
    2021-01-23 16:54

    If you want to capture part of the query string, you must use a RewriteCond with QUERY_STRING

    RewriteEngine On
    RewriteCond %{QUERY_STRING} p=(.+)
    RewriteRule ^/?index.php$ /%1? [R,L]
    

    This redirects the client to the new URL http://www.domain.net/beer.

提交回复
热议问题