htaccess 301将域/文件夹重定向到新的子域

时间:2014-04-10 02:46:07

标签: apache mod-rewrite redirect

我一直在寻找,但无法找到如何进行此重定向。 旧网址是

http://nilandsplace.com/LinuxBlog/

我想将其移至:

http://blog.nilandsplace.com/linux/index.php

我尝试的所有重定向都给了我500服务器错误或找不到此网址的401页/

http://blog.nilandsplace.com/linuxLinuxBlog/

我在根目录/ LinuxBlog /中创建了一个文件夹,我将.htaccess放入。我似乎无法摆脱/ LinuxBlog

1 个答案:

答案 0 :(得分:0)

RewriteEngine On

# if you want to redirect everything to index.php
RewriteCond %{HTTP_HOST} ^nilandsplace\.com$ [NC]
RewriteRule ^LinuxBlog/ http://blog.nilandsplace.com/linux/index.php [R=301]

# if you want to keep the page requested and forward it to the new URL
RewriteCond %{HTTP_HOST} ^nilandsplace\.com$ [NC]
RewriteRule ^LinuxBlog/(.*)$ http://blog.nilandsplace.com/linux/$1 [R=301]