简体   繁体   English

将单个URL重定向到另一个-删除查询字符串

[英]redirect a single URL to another - removing the query string

I have a single url something like this where 456 is the ID of the category and has been rewritten into a seo friendly url: 我有一个类似这样的网址,其中456是类别的ID,并已重写为seo友好的网址:

http://www.mydomain.com/category/nameofcategory/456.htm

(This is done with this rewrite rule: (这是通过以下重写规则完成的:

RewriteRule ^category/.*/([0-9]+) home/categoryview.php?id=$1   [L,QSA]

I need to keep this intact for all the other categories.) 对于其他所有类别,我都需要保持原样。)

I'd like to .htaccess redirect my 456 category to a specific product's url: 我想.htaccess将我的456类别重定向到特定产品的网址:

http://www.mydomain.com/products/nameofproduct/123.htm

If add the following to the .htaccess file 如果将以下内容添加到.htaccess文件中

Redirect 301 /category/nameofcategory/456.htm http://www.mydomain.com/products/nameofproduct/123.htm

then the ID is added to the url and returns another product like this. 然后将ID添加到网址中,并返回其他类似的产品。

http://www.mydomain.com/products/nameofproduct/123.htm?456

Is there a way to remove the '?456' 有没有办法删除“?456”

Don't mix mod_rewrite and mod_alias rules. 不要混用mod_rewritemod_alias规则。 Have all rules in mod_rewrite only. 仅在mod_rewrite具有所有规则。

RewriteEngine On

RewriteRule ^category/[^/]+/456.htm /products/nameofproduct/123.htm? [L,R=301,NC]

RewriteRule ^category/[^/]+/([0-9]+) /home/categoryview.php?id=$1 [L,QSA]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM