【发布时间】:2011-09-16 01:10:09
【问题描述】:
我被困住了。我对 htaccess 了解不多,我只是想了解一下。有人可以看看代码并告诉我它有什么问题。我只是想将旧站点重定向到新站点,唯一的变化是域,一个将在旧/新页面之间匹配的变量以及添加到永久链接结构的单词。
这是我迄今为止尝试过的一种变体:
Options +FolowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^.*domain.com/matchingword1-(.*)-matchingword2-matchingword3/ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/matchingword1-$1-matchingword2-differentword-matchingword3/ [R=301,L]
(.*) 部分将与新域上的 $1 完全相同,但永久链接略有不同。 (.*) 的永久链接部分可以是多个单词和数字中的任何内容。
例如:matchingword1-this-page-is-1st-matchingword2-matchingword3/ 重定向到 newdomain.com/matchingword1-this-page-is-1st-matchingword2-differentword-matchingword3
【问题讨论】:
标签: .htaccess mod-rewrite redirect