mod_rewrite从旧服务器重定向到新服务器

时间:2015-02-17 23:26:26

标签: apache .htaccess mod-rewrite

这听起来像是一个非常简单的任务,我想重定向一个网址,如:

https://oldserver.com/signup/namehttps://newserver.com/sign_up/?alias=name

关于此场景的mod_rewrite文档(here)失败。

我的.htaccess到目前为止是:

RewriteEngine On
RewriteRule ^/signup/(.+) https://newsite.com/sign_up/?alias=$1 [R,L]

# Catch-all
RewriteRule ^(.*)$ https://newsite.com/$1 [R=301,L]

有人可以告诉我可能出现的问题吗?

修改

添加

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f

在第一次重写规则之前仍然会产生404

1 个答案:

答案 0 :(得分:1)

RewriteRule ^/signup/(.+) https://newsite.com/sign_up/?alias=$1 [R,L]

应该是

RewriteRule ^signup/(.+) https://newsite.com/sign_up/?alias=$1 [R,L]

(没有/ signup之前)

相关问题