将旧的.asp链接重定向到新的url



该网站最初托管在Windows Server上,使用.asp编程语言创建。现在,它已经被转移到运行cPanel/WHM的linux服务器上,新网站是使用Wordpress和WooCommerce构建的(该网站是一个在线商店)。

我需要做一些.htaccess重定向从旧的.asp网址到新的链接

示例:

old URL: http://website.com.au/products.asp?cat=110
new URL: http://www.website.com.au/product-category/pearls/

我尝试的是:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
Redirect 301 /products.asp?cat=110 http://www.website.com.au/product-category/pearls/

由于某种原因,重定向不起作用,我收到了一个404页面未找到的错误。

任何帮助都将不胜感激!

您不能在重定向指令中与查询字符串匹配,您需要使用rewriteCond与查询字符串进行匹配,请尝试:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^cat=110$
RewriteRule ^products.asp$ http://website.com.au/product-category/pearls/? [L,NC,R]

如果您不想将旧的查询字符串附加到目标url,那么在目标url末尾添加一个空问号是很重要的。

最新更新