从子域的Apache重写到www,但把所有的永久链接 [英] Apache rewrite from subdomain to www but keep all permalinks

查看:120
本文介绍了从子域的Apache重写到www,但把所有的永久链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我研究过这个,现在约2小时,虽然大部分的主题是相似的,但没有解释了如何做我想要做的。

I've researched this for about 2 hours now and although most of the topics are similar, none have explained how to do what I'd like to do.

我是在一个博客,有blog.domain.com的结构,移动它以www.domain.com/blog/~~V。我需要保持的博客文章的永久链接,当我重定向等等...

I'm taking a blog that had a structure of blog.domain.com and moving it to www.domain.com/blog/. I need to keep the permalink of the blog post when I redirect so...

blog.domain.com/here-is-a-blog-post /

应该成为:

www.domain.com/blog/here-is-a-blog-post/

在尝试很多东西,这是过去的事情我想有没有影响到所有这一切结束了。含义blog.domain.com只是坐在blog.domain.com /

After trying many things, this is the last thing I tried which ends up having no affect at all. Meaning blog.domain.com just sits at blog.domain.com/

RewriteEngine on
RewriteCond %{HTTP_HOST} ^xyz\.domain\.com$
RewriteRule ^/(.*) http://domain.com/$1 [redirect,last]

下面是从我的httpd.conf文件中的条目。

Here's the entry from my httpd.conf file.

<VirtualHost xxx.xxx.xxx.xxx:80>
    SSLEngine off
    SuexecUserGroup apache apache
    ServerName      www.domain.com
    ServerAlias     domain.com
    ServerAlias     blog.domain.com
    ServerAdmin    webmaster@domain.wiredground.com
    DocumentRoot   /home/domain/www/domain.wiredground.com
    ScriptAlias    /cgi-bin/ "/home/domain/www/cgi-bin/"
    <Directory /home/domain/www/cgi-bin>
        AllowOverride None
        Options ExecCGI
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

谁能帮助?

谢谢!

推荐答案

使用这样的:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog\.domain\.com [NC]
RewriteRule (.*) http://domain.com/blog/$1 [R=301,L]

这篇关于从子域的Apache重写到www,但把所有的永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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