多页301重定向多页到1页

时间:2014-05-11 14:12:03

标签: php .htaccess redirect

我有一个包含数百种产品和许多页面的网站,我已使用此规则重定向所有页面

Redirect permanent /about-us/ http://www.domain.com/wedding-blog/about

但是现在我需要将我的所有产品重定向到另一个域名页面,所有产品链接都是这样的

/shopping/category.php?c=009591

他们是否可以通过单一重定向规则将我在/ shopping /下的所有产品重定向到另一个域名购物页面?

2 个答案:

答案 0 :(得分:0)

您必须使用mod_rewrite规则来匹配查询字符串,并且最好将早期规则转换为mod_rewrite

RewriteEngine On

RewriteRule ^about-us/?$ /wedding-blog/about [NC,L,R=301]

RewriteCond %{QUERY_STRING} ^c=009591$
RewriteRule ^category\.php$ /some-page? [NC,L,R=301]

答案 1 :(得分:0)

这应该有效:

RewriteEngine On

RedirectMatch 301 ^/shopping/(.*) http://example.com/shopping/

它会将/shopping/中的任何内容重定向到example.com/shopping/

编辑:

RewriteRule ^shopping/(.*)$ http://example.com/shopping.html? [R=301,L]