替换url路径htaccess



我有一个关于在.htaccess.中重定向旧页面路径的问题

链接https://www.yourwebsite.com/products/product.php?id=44352

需要重定向到https://www.yourwebsite.com/product?id=44352

这意味着id必须保留在url中,但删除/products文件夹和.php扩展名。

我试过了:

RewriteCond %{REQUEST_URI} ^/products/product.php?type=?$ 
RewriteRule (.*) https://www.yourwebsite.com/product?type=$1 [R=301,L] 

但它不起作用。

这应该是您想要的:

RewriteEngine on
RewriteRule ^/?products/product.php$ https://example.com/product [R=301,QSA]

最新更新