2010-11-06 96 views
0

我的网站上有友好的网址,但旧网址仍然有效,而Google一直在索引它们而不是漂亮的网址。 这个平台叫做prestashop。需要301动态网址的重定向帮助

所以我需要重定向这种网址:

site.com/category.php?id_category=20

site.com/product.php?id_product=398

本这类网址:

site.com/the-name-of-category-with-id20

site.com/the-name-of-category-with-id20/the-name-of-product -with-id398.html

我一直在读最近2天有关htaccess,但我想我太愚蠢了解决。

回答

1

您需要使用重写模块(mod_rewrite的):

放到你的.htaccess:

RewriteEngine On 
RewriteRule /the-name-of-category-with-id([0-9]+) /category.php?id_category=$1 [R,NC] 

或静态:

RewriteEngine On 
RewriteRule /catabc /category.php?id_category=20 [R,NC] 
0

TX,你的代码看起来不错,但我相信它只会重写网址? 我已经有了新的网址,我只需要重定向到它们,这样我就不会在Google中看到重复的网页。

我的.htaccess包含此:

URL重写规则

重写规则^([A-Z0-9] +) - ([A-Z0-9] +)( - [_ A- zA-Z0-9 - ] *)/([_ a-zA-Z0-9 - ] *)jpg $ /5com/img/p/$1-$2$3.jpg [L,E]

RewriteRule^([0-9] +) - ([0-9] +)/([_ a-zA-Z0-9 - ] *)。jpg $ /5com/img/p/$1-$2.jpg [L,E ]

RewriteRule ^([0-9] +)( - [_ a-zA-Z0-9 - ] *)/([_ a-zA-Z0-9 - ] *)。jpg $/5com/img /c/$1$2.jpg [L,E]

RewriteRule^lang - ([az] {2})/([a-zA-Z0-9-] )/([0-9] +) - ([a-zA-Z0-9-])的.html(*)$ /5com/product.php?id_product=$3 & isolang = $ 1 $ 5 L,E]

重写规则^郎 - ([AZ] {2})/([0 -9] +) - ([a-zA-Z0-9-] ).html(。)$ /5com/product.php?id_product=$2 & isolang = $ 1 $ 4 L,E]

重写规则^郎 - ([AZ] {2})/([0-9] +) - ( [A-ZA-Z0-9-] )(。)$ /5com/category.php?id_category=$2 & isolang = $ 1 [QSA,L,E]

重写规则^([A-ZA- Z0-9-] )/([0-9] +) - ([a-zA-Z0-9-]).html(。*)$ /5com/product.php?id_product=$2$4 [L ,E]

RewriteRule ^([0-9] +) - ([a-zA-Z0-9-] ).html(。)$ /5com/product.php?id_product=$1$3 [L,E

重写规则^([0-9] +) - ([A-Z0-9- )( )$ /5com/category.php?id_category=$1 [QSA,L,E

重写规则^含量/([0-9] +) - ([A-Z0-9- )( 。)$ /5com/cms.php?id_cms=$1 [QSA,L,E

重写规则^([0-9] +)佩特([A-Z0-9- )( 。)$ /5com/supplier.php?id_supplier=$1$3 [QSA,L,E

重写规则^([0-9] +)_([A-Z0-9- )(。)$ /5com/manufacturer.php?id_manufacturer=$1$3 [QSA,L,E

重写规则^郎 - ?([AZ] {2})/(*)$/5com/$ 2 Isolang = $ 1 [QSA,L,E