mod-rewrite子域到主域中的路径 [英] mod-rewrite subdomain to path in primary domain
问题描述
我有一个子域中另一台服务器上的内容,我想将其用作子目录.sub.domain.com中的所有内容都应该可以访问domain.com/sub,我希望子文件夹也可以正常工作,例如:sub.domain.com/about应该是domain.com/sub/about
I have content from a different server on a subdomain that I would like to use as a subdirectory. Everything from sub.domain.com should be accessible to domain.com/sub I would like sub folders to work as well ex: sub.domain.com/about should be domain.com/sub/about
这是我当前的.htaccess内容
Here's my current .htaccess contents
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(sorry).* - [NC,L]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
任何帮助表示赞赏.谢谢!
Any help appreciated. Thanks!
推荐答案
通过 httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放入您的 .htaccess
下 DOCUMENT_ROOT
目录:
Enable mod_rewrite and .htaccess through httpd.conf
and then put this code in your .htaccess
under DOCUMENT_ROOT
directory:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^sub\.domain\.com$ [NC]
RewriteRule ^ http://domain.com/sub%{REQUEST_URI} [R=301,L,NE]
这篇关于mod-rewrite子域到主域中的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!