mod重写什么和放在哪里

时间:2011-05-24 16:26:35

标签: .htaccess mod-rewrite

我使用mod重写(.htaccess)来:

  1. /index.file发送至/
  2. 将非www发送至www
  3. 现在我想将我的网页从/2.html重命名为/words.html/3.html改为/text.html等。

    RewriteRule ^old\.html$ new.html  [R=301, L]   --possible script?
    

    使用 301重定向/重写(?)订单的最佳方法是什么,即我知道以上两个是正确的顺序 - 但这些新的重定向/重写位置在哪里? (首先或在#1和2之后。)

2 个答案:

答案 0 :(得分:0)

执行此操作的最佳方法是使用Redirect指令

Redirect permanent /one http://example.com/two

将它放在.htaccess文件中。 See explanation here

答案 1 :(得分:0)

只需将这些行附加到现有的.htaccess文件中:

RewriteRule ^2\.html/?$ /words.html [R=301,NC,L]
RewriteRule ^3\.html/?$ /text.html [R=301,NC,L]