mod-rewrite子域到主域中的路径 [英] mod-rewrite subdomain to path in primary domain

查看:62
本文介绍了mod-rewrite子域到主域中的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个子域中另一台服务器上的内容,我想将其用作子目录.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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆