301重定向通过.htaccess php?i2 = sajsak到productname.html - 不是毯子

时间:2011-04-09 16:31:54

标签: .htaccess redirect

好的,所以我正在尝试直接重定向:

store.php?StoreLevel = 3& PrevStoreLevel = 1& productid = 6067& Level1 = 155& p = 5& term =& BrowseBy = 0

重定向到:

mynewproductname.html

我不是在寻找一次大小适合所有重写规则,每一个都有一个相应的.html计数器部分,所以有点“硬编码”

这些适用于301和Google排名

我无法弄清楚这一点。我找到的所有资源都给了我关于如何将一个镜头中的所有php链接转换为具有相同名称的html对应的一揽子规则。我不打算这样做。

我尝试了很多东西,没有工作。我的一些尝试:

RewriteRule ^ store.php?StoreLevel = 3& PrevStoreLevel = 1& productid = 6067& Level1 = 155& p = 5& term =& BrowseBy = 0 $ mynewproductname.html [R = 301,L]

RewriteCond%{QUERY_STRING} = store.php?StoreLevel = 3& PrevStoreLevel = 1& productid = 6067& Level1 = 155& p = 5& term =& BrowseBy = 0 RewriteRule mynewproductname.html [R = 301,L]

RewriteCond%{QUERY_STRING} ^ StoreLevel = 3& PrevStoreLevel = 1& productid = 6067& Level1 = 155& p = 5& term =& BrowseBy = 0 $ RewriteRule ^ store.php $ http://mysite.com/mynewproductname.html? [R = 301,L]

其中一些会导致500服务器错误,有些则无法正常工作。非常感谢协助。

编辑 - mod_rewrite已启用且工作正常,能够重定向:

RewriteRule ^ foo $ http://mysite.com/testing.html [R = 301,L]

成功

1 个答案:

答案 0 :(得分:0)

您可以尝试从.php文件中重定向,而不是使用.htaccess。有一个productid =>的查找表首次加载.php时扫描的网页;如果你得到一个匹配,返回301.如果你不匹配,继续定期.php处理(或404,视情况而定)