url将`/ abc / products -`重写为`/ def / products -`

时间:2012-10-12 13:10:07

标签: apache .htaccess url-rewriting

我在/abc/子目录中有很多网址链接,比如

http://www.domain.com/abc/products-12345
http://www.domain.com/abc/products-23456
http://www.domain.com/abc/products-34567
http://www.domain.com/abc/new-items

现在我要url rewrite /abc/products-/def/products-

http://www.domain.com/def/products-12345
http://www.domain.com/def/products-23456
http://www.domain.com/def/products-34567
http://www.domain.com/abc/new-items

我的代码在.htaccess,但没有任何改变。在这种情况下如何重写?感谢。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^abc/products-(.*)$ /def/products-$1 [L,R=301]
</IfModule>

1 个答案:

答案 0 :(得分:1)

正如您可以在this simulator上测试规则应该有效。

您面临的最可能的问题应该是:

  • 全局配置不允许.htaccess覆盖
  • .htaccess对于apache用户不可读
  • 此apache服务器上没有活动的mod_rewrite,因此没有触发<IfModule>指令。

最佳故障排除选项是尝试将所有页面重定向到静态页面。如果这不起作用,请查找配置问题。

相关问题