不幸的是,我的一位客户在他使用的托管公司使用 Zeus Web 服务器。我以前从未使用过它。
我需要设置简单的 301 重定向,但 Zeus 不使用 .htaccess,它使用自己的文件 rewrite.script
有谁知道如何为 Zeus 使用 rewrite.script 进行基本的 301 重定向?相当于:
重定向 301 /pagename http://domain.com/newpage.php
在 .htaccess 中。
实际文件名也发生了变化,所以我不能直接重定向整个域,我需要为所有 20 个页面设置单独的 301 重定向。
我已经尝试了下面某人在 stackoverflow 上发布的建议,以及我在另一个网站上找到的建议,但都被忽略了。主机是否需要启用某些功能?我知道 rewrite.script 正在被读取,因为我将它用于搜索引擎友好的 URL。
#— 301 Redirect —
match URL into $ with ^/old.html$
if matched
set OUT:Location = http://www.yourdomain.co.uk/new.html
set OUT:Content-Type = text/html
set RESPONSE = 301
set BODY = Moved
goto END
endif
这是我的整个 rewrite.script
#Zeus webserver version of basic WordPress mod_rewrite rules
map path into SCRATCH:path from %{URL}
look for file at %{SCRATCH:path}
if exists then goto END
look for dir at %{SCRATCH:path}
if exists then goto END
##### FIX FOR LOGIN/FORGOTTEN PASSWORD/ADMIN ETC #####
match URL into $ with ^/wp-.*$
if matched then goto END
##### FIX TO ALLOW SEARCH TO WORK #####
match URL into $ with ^/(.*)
set URL = /$1
RULE_0_START:
match URL into $ with ^\/pagename$
if not matched then goto RULE_1_END
if matched then
set URL = http://domain.com/newpage.php
set RESPONSE = 301
set OUT:Location = %{URL}
set BODY = Please try <a href="%{URL}">here</a> instead\n
goto END
RULE_0_END: