PHP When rewrite pages urls how to remove or redirect category.php?cat_id=2 urls to rewrited urls?

前端 未结 2 1595
再見小時候
再見小時候 2021-01-26 12:04

I am using this URL rewriting with PHP The Folder structure for rewriting the URLs. I am done it is working fine but after rewrite the URLs then ok now i have two URLs one is si

2条回答
  •  伪装坚强ぢ
    2021-01-26 12:56

    At the top of your htaccess , put the following rule :

    RewriteEngine on
    
    RewriteCond %{QUERY_STRING} ^cat_id=2$ [NC]
    RewriteRule category.php$ http://199.192.21.232/~admin/product-category/men-items? [L,R=302]
    

    This will redirect http://199.192.21.232/~admin/product-category.php?cat_id=2 to http://199.192.21.232/~admin/product-category/men-items .

    In case you have multiple old URLs with the same queryString , just change the condition pattern from ^cat_id=2$ to ^cat_id=.+$ . When you are sure the redirect is working fine change R=302 to R=301 to make the Redirection permanent .

提交回复
热议问题