0

I could redirect subdomain to subdirectory:

sub.domain.com > www.domain.com/sub

By using:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub.domain.com [NC]
RewriteRule (.*) www.domain.com/sub/$1 [R=301,L]

However, the page at www.domain.com/sub displayed nothing but this:

Index of /sub
Parent Directory
Apache Server at www.domain.com Port 80

I have a working website with contents at sub.domain.com. How can I load the same website and make it work at www.domain.com/sub ?

Thank you.

4

1 回答 1

0

Jon 是对的,你需要移动内容。然后你只需要通过http://在目标域前面添加来重定向来自旧子域的传入请求来修复你的重定向:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.domain\.com [NC]
RewriteRule (.*) http://www.domain.com/sub/$1 [R=301,L]
于 2012-12-04T08:43:36.253 回答