问题描述
我有一个URL这样的事情,其中456是该类别的ID,并已改写成搜索引擎友好的URL:
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:
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.)
我想为.htaccess重定向我456类特定产品的网址:
I'd like to .htaccess redirect my 456 category to a specific product's url:
http://www.mydomain.com/products/nameofproduct/123.htm
如果添加以下到.htaccess文件
If add the following to the .htaccess file
Redirect 301 /category/nameofcategory/456.htm http://www.mydomain.com/products/nameofproduct/123.htm
则ID加到url并返回另一个产品这样
then the ID is added to the url and returns another product like this.
http://www.mydomain.com/products/nameofproduct/123.htm?456
有没有办法去除'?456
Is there a way to remove the '?456'
推荐答案
不要混合使用的mod_rewrite
和 mod_alias中
规则。在的mod_rewrite
只有所有规则。
Don't mix mod_rewrite
and mod_alias
rules. Have all rules in mod_rewrite
only.
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]
这篇关于重定向单个URL到另一个 - 除去查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!