2013-10-25 39 views
0

我正在迁移一个网站到不同的根域,我试图将所有旧的网址重定向到新的。大多数网址都正确重定向,但一对夫妇被炒得沸沸扬扬。例如pythonforspss.org/solutions重定向到http://www.spss-tutorials.com/python/solutions而不是http://www.spss-tutorials.com/python.htaccess主要工作,但生成一些不正确的网址

由于目标网址对我来说似乎很清楚,我只是不明白发生了什么问题。这可能与Rewrite规则有关,但我看不到如何解决它。

UPDATE

我尝试了很多修改,但症状仍然是完全一样的。整个.htaccess(我为它的长度道歉)在这一点上:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^get-started$ http://www.spss-tutorials.com/python/ [L,R=301] 
RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^solutions$ http://www.spss-tutorials.com/python/ [L,R=301] 
RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^spss-tips$ http://www.spss-tutorials.com/basics/ [L,R=301] 
RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^glossary$ http://www.spss-tutorials.com/glossary/ [L,R=301] 
RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteCond %{THE_REQUEST} \ /.*index\.php 
RewriteRule ^index\.php$ http://www.spss-tutorials.com/python/ [L,R=301] 
RewriteRule . /index.php [L] 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
</IfModule> 

#First redirect single pages 
Redirect 301 /how-to-write-very-short-syntax http://www.spss-tutorials.com/write-shorter-syntax/ 
Redirect 301 /how-to-suffix-all-variable-names http://www.spss-tutorials.com/suffix-all-variable-names/ 
Redirect 301 /five-essential-data-checks http://www.spss-tutorials.com/five-essential-data-checks/ 
Redirect 301 /the-twenty-best-keyboard-shortcuts-for-spss http://www.spss-tutorials.com/the-twenty-best-keyboard-shortcuts-for-spss/ 
Redirect 301 /assemble-your-own-toolbar http://www.spss-tutorials.com/assemble-your-own-toolbar/ 
Redirect 301 /disclaimer http://www.spss-tutorials.com/disclaimer/ 
Redirect 301 /select-variables-by-variable-labels http://www.spss-tutorials.com/select-variables-by-variable-labels/ 
Redirect 301 /five-reasons-for-not-relying-on-the-journal-file http://www.spss-tutorials.com/five-reasons-for-not-relying-on-the-journal-file/ 
Redirect 301 /introducing-python-4-installing-and-testing http://www.spss-tutorials.com/introducing-python-4-installing-and-testing/ 
Redirect 301 /create-your-own-toolbar-tools http://www.spss-tutorials.com/create-your-own-toolbar-tools/ 
Redirect 301 /concatenate http://www.spss-tutorials.com/concatenate/ 
Redirect 301 /indentation http://www.spss-tutorials.com/indentation/ 
Redirect 301 /leave http://www.spss-tutorials.com/leave/ 
Redirect 301 /convert-a-number-as-a-date-into-a-date-variable http://www.spss-tutorials.com/convert-a-number-as-a-date-into-an-spss-date/ 
Redirect 301 /introducing-python-2-how-it-basically-works http://www.spss-tutorials.com/introducing-python-2-how-it-basically-works/ 
Redirect 301 /set-decimals-for-output http://www.spss-tutorials.com/set-decimals-for-output/ 
Redirect 301 /compute-age http://www.spss-tutorials.com/compute-age/ 
Redirect 301 /date-variable http://www.spss-tutorials.com/date-variable/ 
Redirect 301 /modulus http://www.spss-tutorials.com/modulus/ 
Redirect 301 /how-to-convert-a-unix-date-to-an-spss-date http://www.spss-tutorials.com/convert-unix-dates-into-spss-dates/ 
Redirect 301 /time-variable http://www.spss-tutorials.com/time-variable/ 
Redirect 301 /how-to-convert-dates-from-google-analytics http://www.spss-tutorials.com/convert-google-analytics-dates-into-spss-dates/ 
Redirect 301 /how-to-extract-a-year-from-a-date http://www.spss-tutorials.com/extract-a-year-from-a-date/ 
Redirect 301 /use-the-command-syntax-reference http://www.spss-tutorials.com/command-syntax-reference/ 
Redirect 301 /change-your-working-directory http://www.spss-tutorials.com/change-your-working-directory/ 
Redirect 301 /select-variables-having-pattern-in-names http://www.spss-tutorials.com/select-variables-having-pattern-in-names/ 
Redirect 301 /split-string-variable-into-components http://www.spss-tutorials.com/split-string-variable-into-components/ 
Redirect 301 /find-within-subjects-favorite-over-several-variables http://www.spss-tutorials.com/find-within-subjects-favorite-over-several-variables/ 
Redirect 301 /prefix-many-value-labels http://www.spss-tutorials.com/prefix-many-value-labels/ 
Redirect 301 /strip-prefix-from-value-labels http://www.spss-tutorials.com/strip-prefix-from-value-labels/ 
Redirect 301 /rename-or-prefix-many-files http://www.spss-tutorials.com/rename-or-prefix-many-files/ 
Redirect 301 /move-all-files-from-subfolders-to-main-folder http://www.spss-tutorials.com/move-all-files-from-subfolders-to-main-folder/ 
Redirect 301 /copy-all-files-from-subfolders-to-main-folder http://www.spss-tutorials.com/copy-all-files-from-subfolders-to-main-folder/ 
Redirect 301 /find-which-syntax-files-contain-some-expression http://www.spss-tutorials.com/find-which-syntax-files-contain-some-expression/ 
Redirect 301 /add-filenames-to-files-before-merging http://www.spss-tutorials.com/add-filenames-to-files-before-merging/ 
Redirect 301 /adjust-string-lengths-before-merging-files http://www.spss-tutorials.com/adjust-string-lengths-before-merging-files/ 
Redirect 301 /merge-many-data-files http://www.spss-tutorials.com/merge-many-data-files/ 
Redirect 301 /regression-over-many-dependent-variables http://www.spss-tutorials.com/regression-over-many-dependent-variables/ 
Redirect 301 /create-dummy-variables http://www.spss-tutorials.com/create-dummy-variables/ 
Redirect 301 /mean-center-many-variables http://www.spss-tutorials.com/mean-center-many-variables/ 
Redirect 301 /export-output-to-different-folders http://www.spss-tutorials.com/export-output-to-different-folders/ 
Redirect 301 /insert-values-from-output-tables-into-text http://www.spss-tutorials.com/insert-values-from-output-tables-into-text/ 
Redirect 301 /loop http://www.spss-tutorials.com/loop/ 
Redirect 301 /macro http://www.spss-tutorials.com/macro/ 
Redirect 301 /module http://www.spss-tutorials.com/module/ 
Redirect 301 /path http://www.spss-tutorials.com/path/ 
Redirect 301 /transformation-command http://www.spss-tutorials.com/transformation-command/ 
Redirect 301 /procedure http://www.spss-tutorials.com/procedure/ 
Redirect 301 /substring http://www.spss-tutorials.com/substring/ 
Redirect 301 /string http://www.spss-tutorials.com/string/ 
Redirect 301 /strip-prefix-from-variable-labels http://www.spss-tutorials.com/strip-prefix-from-variable-labels/ 
Redirect 301 /managing-variable-properties-1-introduction http://www.spss-tutorials.com/changing-variable-properties-1-introduction/ 
Redirect 301 /managing-variable-properties-2-names http://www.spss-tutorials.com/changing-variable-properties-2-names/ 
Redirect 301 /managing-variable-properties-3-type http://www.spss-tutorials.com/changing-variable-properties-3-type/ 
Redirect 301 /managing-variable-properties-4-width-and-decimals http://www.spss-tutorials.com/changing-variable-properties-4-width-and-decimals/ 
Redirect 301 /managing-variable-properties-5-variable-and-value-labels http://www.spss-tutorials.com/changing-variable-properties-5-variable-and-value-labels/ 
Redirect 301 /managing-variable-properties-6-missing-values-and-more http://www.spss-tutorials.com/changing-variable-properties-6-missing-values-and-more/ 
Redirect 301 /escape-sequence http://www.spss-tutorials.com/escape-sequence/ 
Redirect 301 /cautionary-note-on-sums http://www.spss-tutorials.com/spss-sum-cautionary-note/ 
Redirect 301 /cautionary-note-on-the-add-files-command http://www.spss-tutorials.com/spss-add-files-cautionary-note/ 
Redirect 301 /how-to-sort-values-within-cases http://www.spss-tutorials.com/sort-values-within-cases/ 
Redirect 301 /extension-command http://www.spss-tutorials.com/extension-command/ 
Redirect 301 /read-and-merge-multiple-sheet-excel-workbooks http://www.spss-tutorials.com/read-and-merge-multiple-sheet-excel-workbooks/ 
Redirect 301 /xlrd http://www.spss-tutorials.com/xlrd/ 
Redirect 301 /compare-dictionaries-over-files-before-merging http://www.spss-tutorials.com/compare-dictionaries-over-files-before-merging/ 
Redirect 301 /how-to-disaggregate-weighted-data http://www.spss-tutorials.com/disaggregate-data/ 
Redirect 301 /any http://www.spss-tutorials.com/any/ 
Redirect 301 /missing-values http://www.spss-tutorials.com/missing-values/ 
Redirect 301 /assumption-of-equal-intervals http://www.spss-tutorials.com/assumption-of-equal-intervals/ 
Redirect 301 /variable-type http://www.spss-tutorials.com/variable-type/ 
Redirect 301 /compute-a-is-b-is-c http://www.spss-tutorials.com/compute-a-is-b-is-c/ 
Redirect 301 /reverse-code-variables-with-value-labels http://www.spss-tutorials.com/reverse-code-variables-with-value-labels/ 
Redirect 301 /spss-recode-command-cautionary-note http://www.spss-tutorials.com/spss-recode-command-cautionary-note/ 
Redirect 301 /aggregate http://www.spss-tutorials.com/aggregate/ 
Redirect 301 /very-first-steps http://www.spss-tutorials.com/spss-very-first-steps/ 
Redirect 301 /names-and-labels-in-output http://www.spss-tutorials.com/names-and-labels-in-output/ 
Redirect 301 /hire-us http://www.spss-tutorials.com/hire-us/ 
Redirect 301 /home http://www.spss-tutorials.com/home/ 
Redirect 301 /introducing-python-1-what-and-why http://www.spss-tutorials.com/introducing-python-1-what-and-why/ 
Redirect 301 /introducing-python-5-five-essential-basics http://www.spss-tutorials.com/introducing-python-5-five-essential-basics/ 
Redirect 301 /introducing-python-6-four-tips http://www.spss-tutorials.com/introducing-python-6-four-tips/ 
Redirect 301 /introducing-python-3-how-to-use-it http://www.spss-tutorials.com/introducing-python-3-how-to-use-it/ 
Redirect 301 /the-six-greatest-benefits-of-using-spss-syntax http://www.spss-tutorials.com/the-six-greatest-benefits-of-using-spss-syntax/ 

#Ancient static html 
Redirect 301 /getting-started.html http://www.spss-tutorials.com/python/ 
Redirect 301 /solutions.html http://www.spss-tutorials.com/python/ 

回答

1

那些重定向没有为我工作,而无需一个斜线:

Redirect 301 /solutions http://www.spss-tutorials.com/python/ 

但它并不总是一个好想法混合mod_rewrite和mod_alias指令(Redirect是mod_alias的一部分),因为它们都应用于相同的URI,并且你并不总是希望发生这种情况。尝试更改所有Redirect s到:

RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^get-started$ http://www.spss-tutorials.com/python/ [L,R=301] 

RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^solutions$ http://www.spss-tutorials.com/python/ [L,R=301] 

RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^spss-tips$ http://www.spss-tutorials.com/basics/ [L,R=301] 

RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteRule ^glossary$ http://www.spss-tutorials.com/glossary/ [L,R=301] 

RewriteCond %{HTTP_HOST} pythonforspss\.org$ [NC] 
RewriteCond %{THE_REQUEST} \ /.*index\.php 
RewriteRule ^index\.php$ http://www.spss-tutorials.com/python/ [L,R=301] 
+0

谢谢,但它还没有工作。我应该** **都将斜杠添加到'Redirect'规则**并**将这些'RewriteCond'行添加到'Rewrite'部分?我这样做了,但似乎没有改变这个问题。我应该发布整个'.htaccess'文件吗?这是相当长的(119行)... – RubenGeert

+0

@RubenGeert你需要删除所有的'重定向'语句并将其替换为上面的mod_rewrite规则。规则需要在任何其他规则之前(尤其是wordpress规则) –

+0

我不知道为什么,但事情似乎现在工作!也许这是'Filezilla'中的更新,但我认为这不会对服务器上发生的事情产生任何影响。无论如何,thx一百万! – RubenGeert

相关问题