htaccess的重定向〜[fake-subdomain.domain.com/*]至[domain.com/*] [英] .htaccess redirect ~ [fake-subdomain.domain.com/*] to [domain.com/*]

查看:231
本文介绍了htaccess的重定向〜[fake-subdomain.domain.com/*]至[domain.com/*]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找这几个小时,我不知道如何来实现这一目标。我需要做以下301永久重定向:

当人们访问 http://web.domain.com.br/something/

它们应重定向到 http://domain.com.br/something/

在哪里(重要!),在 /事/ 是不是一个真正的目录, 它是一个子博客从字preSS的多站点安装。 有对已经在行动了根.htaccess文件的另一个规则。它们是:


    RewriteEngine叙述上
    的RewriteBase /
    重写规则^指数\ .PHP $  -  [L]

    #上传的文件
    重写规则^([_ 0-9A-ZA-Z  - ] + /)?文件/(.+)WP-包括/ MS-files.php文件= $ 2 [L]

    #添加斜线到/可湿性粉剂管理员
    重写规则^([_ 0-9A-ZA-Z  - ] + /)?WP-ADMIN $ $ 1WP管理员/ [R = 301,L]

    的RewriteCond%{} REQUEST_FILENAME -f [OR]
    的RewriteCond%{} REQUEST_FILENAME -d
    重写规则^  -  [L]
    重写规则^ [_ 0-9A-ZA-Z  - ] + /(WP-(内容|管理|包括)*)$ 1 [L]
    重写规则^ [_ 0-9A-ZA-Z  - ] + /(。* \ PHP)$ $ 1 [L]
    重写规则。的index.php [L]

我的域名实际上已经拥有了某种重定向,离开我的视线,有人在控制面板上创建的。他们确实创造了以下内容:

当您访问: http://web.domain.com.br/

您去: http://domain.com.br/

有关家庭的一部分,这是确定的。 但每当我试着这么做: http://web.domain.com.br/opaopa/

我被重定向到: http://domain.com.br/

和,如果我phisically创建我的根里面的目录/ opaopa / 重定向trhows我有......但是,我不能为我的话preSS子网站真正的目录,因为Apache提供的,而不是装载字$ P $的神奇preference给他们, PSS的多站点网络。

如果这听起来令人困惑对不起... 英语不是我的自然语言。

感谢SOOO多的关注。 问候, -G。

解决方案

 的RewriteCond%{HTTP_HOST}!^域\ .COM \ .BR $ [NC]
重写规则(。*)http://domain.com.br/$1 [L,R = 301]
 

就在的RewriteBase ... 添加这个(所以所有其他不可改写规则之前)

I have been searching for this for many hours and I have no idea how to accomplish that. I need to make the following 301 permanent redirect:

When people visit http://web.domain.com.br/something/

They should be redirected to http://domain.com.br/something/

Where (important!), the /something/ is not a real directory, it is a sub-blog from the wordpress multisite installation. There are another rules on the root .htaccess file already in action. They are:


    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # uploaded files
    RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]

    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule  ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]
    RewriteRule  ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]
    RewriteRule . index.php [L]

My domain actually already has a some kind of redirect, out of my sight, created by someone on the control panel. They did create the following:

When you visit: http://web.domain.com.br/

You go to: http://domain.com.br/

For the home part, this is ok. But whenever I try something like: http://web.domain.com.br/opaopa/

I got redirected to: http://domain.com.br/

AND, if I phisically create inside my root the directory /opaopa/ the redirect trhows me there... However, I can't create real directories for my wordpress subsites, because the apache gives preference to them, instead of loading the "magic" of the wordpress multisite network.

Sorry if it sounds confusing... English is not my natural language.

Thanks sooo much for your attention. Regards, G.

解决方案

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

add this just after RewriteBase ... (so before all the other rewrite-rules)

这篇关于htaccess的重定向〜[fake-subdomain.domain.com/*]至[domain.com/*]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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