.htaccess只将index.php重定向到新站点

时间:2011-12-19 00:16:19

标签: .htaccess redirect

我们正在开发新网站,我们希望将主页重定向到一个子目录,我想知道如何使用.htaccess执行此操作,然后再将其他任何页面返回到旧网站。< / p>

2 个答案:

答案 0 :(得分:-1)

这些规则会将http://yourdomain.example.com转发给http://yourdomain.example.com/yoursubdir/

RewriteEngine on
RewriteRule ^/?$ yoursubdir/ [L]

相反,如果您希望使用index.php重定向网址(例如http://yourdomain.example.com/index.php,请使用此规则。

RewriteEngine on
RewriteRule ^index.php$ yoursubdir/ [L]

一般来看看mod_rewrite的文档。网上有许多有用且免费的指南。

答案 1 :(得分:-1)

这样的事情可以解决问题

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com/some/subdir/$1 [R=301,L]

这会将请求的URI重写为newdomain.com的某些/ subdir